开发者

jQuery: pass data with $.getScript?

开发者 https://www.devze.com 2023-01-24 10:17 出处:网络
Can i pass data to the function youtu开发者_Go百科beFetchDataCallback in this: $.getScript( \'gdata.youtube.com/feeds/api/… echo $m; ?>?v=2&alt=json-in-script&callback=youtubeFetchDataCal

Can i pass data to the function youtu开发者_Go百科beFetchDataCallback in this:

$.getScript( 'gdata.youtube.com/feeds/api/… echo $m; ?>?v=2&alt=json-in-script&callback=youtubeFetchDataCallback' );

e.g i pass data "mode" then inside the function i can alert(mode)


This shows it with an anonymous function; note that the URL is changed to use ? for the callback, so jQuery chooses a function name. However, you can also used a named function in the same scope. Either way, mode is closed in to the function.

var mode = ...;
$.getScript( 'http://gdata.youtube.com/feeds/api/… echo $m; ?>?v=2&alt=json-in-script&callback=?', function()
{
  alert(mode);
});
0

精彩评论

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