I am trying to make a jsonp call to bing map geocode service. depending on what parameters i change, i either get a cross-domain error or return is not script type. however, appending a script tag to do the call without jquery works, so i believe it's an issue with the parameters i'm configuring, i just can't figure out which one.
in the case without jquery, i have to append the callback myself as &jsonp=mycallback. in the case of jquery, i let jquery.ajax append it for me.
- bingURL = 'https://dev.virtualearth.net/REST/v1/Locations?jsonp=mycallback&countryRegion='+encodeURI(country)+'&adminDistrict='+encodeURI(state_prov)+'&locality='+encodeURI(city)+'&postalCode='+encodeURI(postal_code)+'&addressLine='+encodeURI(addr_line_1)+'&includeNeighborhood=0&maxResults=1&key='+this.BING_KEY+'&output=json';
- // works WITHOUT jquery
- var script = document.createElement("script");
- script.setAttribute("type", "text/javascript");
- script.setAttribute("src", bingURL);
- document.body.appendChild(script);
- bingURL2 = 'https://dev.virtualearth.net/REST/v1/Locations?countryRegion='+encodeURI(country)+'&adminDistrict='+encodeURI(state_prov)+'&locality='+encodeURI(city)+'&postalCode='+encodeURI(postal_code)+'&addressLine='+encodeURI(addr_line_1)+'&includeNeighborhood=0&maxResults=1&key='+this.BING_KEY+'&output=json';
- $.ajax({
- datatype: 'jsonp',
- jsonp: 'jsonp', // override the parm name 'callback' with this one needed by bing
- type: 'GET',
- crossDomain: true,
- url: bingURL2
- }).done(function(result) {
- alert('done');
- }).always(function(a,b,c,d,e) {
- alert('what happened?');
- });