-2

我想在通过 php 返回的链接之前显示图像。下面是ajax代码

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

    }
});
4

1 回答 1

0

Just append the image before the link.

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

    }
});
于 2013-08-25T11:33:12.723 回答