我通过ajax将“id”和“data”传递给php。这是jquery ajax代码
1.$.ajax({//Make the Ajax Request 2. type: "POST", 3. url: "dbtryout2_2.php", 4. data:datastr, 5. success: function(arrayphp) 6. { 7. //here iam displaying the returned data. 8. //I wanna display this data as link 9. //because on clicking on it I 10. //again want to call another php script. 11. $(".searchby .searchlist").append(arrayphp); 12. 13. } 14. }); 15. I have not shown the php code.The code is working well. 16.BUT iam unable to display the data as link.I also want to give the data a "class name". 17.PLEASE if anybody know ...fix this problem
答案 0 :(得分:1)
如果php返回的数据只是链接的标签,您可以使用以下代码:
$.ajax({//Make the Ajax Request
type: "POST",
url: "dbtryout2_2.php",
data:datastr,
success: function(arrayphp)
{
var link = $('<a href="#" class="my-class">' + arrayphp + '</a>');
$(".searchby .searchlist").append(link);
}
});