これをガイドとして使用する:http://msdn.microsoft.com/en-us/library/dd250846.aspx
誰かがjquery呼び出しで私を助けることができますか?
実際にコールバックのJavaScriptコードを渡すのですか、それとも関数の名前だけを渡すのですか?
BingSearch = function($bingUrl, $bingAppID, $keyword, $callBack) {
$bingUrl = $bingUrl + "?JsonType=callback&JsonCallback=" + $callBack + "&Appid=" + $bingAppID + "&query=" + encodeURI($keyword) + "&sources=web";
$.ajax({
dataType: 'jsonp',
jsonp: $callBack,
url: $bingUrl,
success: function(data) {
alert('success');
$callBack(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("error: " + textStatus);
}
});
};
アップデート
わかりました。これを次のように変更しました。
BingSearch = function(bingUrl, bingAppID, keyword, callback) {
var url = bingUrl + "?method=?&JsonType=callback&Appid=" + bingAppID + "&query=" + encodeURI(keyword) + "&sources=web";
$.getJSON(url, callback);
};
次のように呼びます:
BingSearch(url, appid, searchkeyword, function(searchresults) {
alert('yes!');
};
それでも「無効なラベル」エラーが発生します。