2013-08-25 43 views
-2

我想在通過php返回鏈接之前顯示圖像。 下面是Ajax代碼在通過php返回鏈接之前顯示圖像

$.ajax({ //Make the Ajax Request 
    type: "POST", 
    url: "dbtryout2_2.php", 
    data: datastr, 
    success: function (arrayphp) { 
     //how to display image before this link 
     var link = $('<a href="#" class="my-class">' + arrayphp + '</a>'); 
     $(".searchby .searchlist").append(link); 

    } 
}); 
+0

我在這裏看不到任何問題。 –

+0

[jQuery「請稍等,正在加載...」動畫?](http://stackoverflow.com/questions/1964839/jquery-please-wait-loading-animation) – amdorra

回答

0

就在鏈接之前的圖像追加。

$.ajax({ //Make the Ajax Request 
    type: "POST", 
    url: "dbtryout2_2.php", 
    data: datastr, 
    success: function (arrayphp) { 
     //how to display image before this link 
     var link = $('' + arrayphp + ''); 
     var image = "<img src='http://www.yourdomain.com/iamge.png' alt='' />" 
     $(".searchby .searchlist").append(image).append(link); 

    } 
}); 
+0

@ LAURYNAS iam顯示鏈接一個接一個通過從一個循環內的PHP,我希望圖像顯示在每個鏈接之前,但在這裏圖像顯示之前只有第一個鏈接,並沒有得到顯示之前鏈接的其餘部分 –

+0

$(「。searchby .searchlist a」)。前置(圖像);這應該做的詭計 –

+0

@ LAURYNAS我編輯了我的代碼的代碼是真實的代碼是你的技巧你告訴不是工作。我描述了我的問題在評論 –