2013-08-18 56 views
0

我傳遞一個「id」和「數據」通過AJAX到PHP。這裏是jQuery的Ajax代碼顯示數據通過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 

回答

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); 

    } 
}); 
+0

非常感謝哥哥......我stucked在這個問題上三個days.Your代碼工作.. –

+0

歡迎您。 (您可以將我的答案標記爲正確,以便其他人也可以使用它)。 – Krasimir

+0

@ krasimir看下面我有一些相關的查詢 –