Bing search API using Jsonp not working, invalid label

Fighting Bing json request (bing search, not map), I get an error message that says "Invalid shortcut"

My request:

var bingurl="http://api.search.live.net/json.aspx?Appid=##APIKEY##&query=Honda&sources=web";


 $.ajax({
            type: "GET",
            url: bingurl,
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "jsonp",
            success: function(data) {

                $callBack(data);
            },
            error: function(msg) {
                alert("error" + msg);
            }
        });

Firebug reports an "invalid shortcut" and then issues a json response.

I don’t know what is wrong? help evaluate.

+3
source share
2 answers

The URL of the Bing URL you submitted is not JSONP, it is just JSON.

JSONP JavaScript, JSON- {"something": ... , , (, ).

,, , JSONP Bing, , , ...&JsonType=callback&JsonCallback= ( ).

( , data: "{}" , , - .)

+7

API Bing REST jsonp, , " " - "jsonp". jQuery jsonp $.ajax() "jsonp", .   

$.ajax({
    url: 'http://some.domain.com',
    dataType: 'jsonp',
    jsonp: 'jsonp'
});`
+4

Source: https://habr.com/ru/post/1745338/


All Articles