开发者

Creating an URL with javascript and a variable for jQuery ajax call

I'm trying to use timthumb to dynamically resize an image using jQuery ajax:

load_link = "/images/timthumb.php&src=" + link + "&h=194&w=263";
    /* /images/timthumb.php&src=http://farm4.static.flickr.com/3631/5836439169_2230db5e6d_m.jpg&h=194&开发者_运维知识库amp;w=263 */

    $.get(load_link, updateLink);

    function updateLink(data) {
        $('#flickr-first-photo').attr('src',data);
    }

But I'm getting no response back from the ajax call. Does anyone know if this is even possible with timthumb?


probably because the URL is not valid. Try to use this:

load_link = "/images/timthumb.php&src=" + encodeURI(link) + "&h=194&w=263";


This worked:

load_link = encodeURI("&src=" + link + "&h=194&w=263&marko=1");
$.get('/images/timthumb.php', load_link, updateLink);

function updateLink(data) {
    $('#flickr-first-photo').attr('src',data);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜