Javascript – Insert hyperlink in a dynamic text which is formed in javascript,and on click, it should hit a servlet

huangapple 未分类评论43阅读模式
英文:

Javascript - Insert hyperlink in a dynamic text which is formed in javascript,and on click, it should hit a servlet

问题

<div id="myDiv"></div>
Javascript代码:
在Ajax调用成功时:

success: function(resp) {
    var currentText = $("#myDiv").html();
    $("#myDiv").html(currentText + "Case : " + textWithLink + " Done<BR/>");
}

我想在textWithLink中插入一个超链接,点击后应该访问一个servlet,比如说myServlet
我当前得到的输出是:
Case ABCDEF Done
Case BHRTYU Done
我希望在ABCDEF和BHRTYU中插入超链接。
谢谢

英文:

I have a javascript function, which has an ajax call, and on success of that call, I am appending a htm text in a div, with a dynamic variable. I want to insert a hyperlink in that dynamic variable, and on click of that hyperlink, it should hit a servlet.

 &lt;div id=&quot;myDiv&quot;&gt;&lt;/div&gt;

Javascript code :
On success of Ajax call :

success: function(resp) {
	var currentText = $(&quot;#myDiv&quot;).html(); 
	$(&quot;#myDiv&quot;).html(currentText + &quot;Case : &quot; + textWithLink+ &quot; Done&lt;BR/&gt;&quot;); 
}

I want to insert a hyperlink in 'textWithLink' and on click it should hit a servlet, say 'myServlet'.
The current output that I am getting is :
Case ABCDEF Done
Case BHRTYU Done
I want to insert hyperlink in ABCDEF and BHRTYU.
Thanks

huangapple
  • 本文由 发表于 2020年7月25日 16:06:22
  • 转载请务必保留本文链接:https://java.coder-hub.com/63085926.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定