开发者

Fetch first element in 'new array' JSONP response with Jquery

I try to keep it simple:

Problem: how to fetch the first element (weight here) from the new Array with JQuery

Current JQuery:

function xyz() 
{
           开发者_高级运维 var the_url = 'http://longurl'+encodeURIComponent(searchBox.val());

            var x1 = $.ajax({
                   type: "GET",
                   url: the_url,
                   dataType: "script"
            });
}

callback_function = function(suggestions)
{
    return suggestions[0];
}

JSONP response:

callback_function("w", new Array("weight", "weight loss", "wound"), 0);


That response isn't JSONP, but may work (never tried the approach), your callback should be looking for the second parameter though, like this:

callback_function = function(something, suggestions, somethingElse)
{
  return suggestions[0];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜