I had this jquery which gets data in jsonp format using ajax GET request which used to work fine for years but suddenly it has stopped working.
But the thing is the same jquery fine when I ran it on my local machine but it didn't works on the server where I have hosted my site. Also the jquery used to work on the jsfiddle but even on jsfiddle when I run the same jquery it gives me the same HTTP 400 error. But the same jquery used to work earlier on jsfiddle.
Here is the snippet which reproduces the issue:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jquery-1.11.1.min.js"> </script>
<script>
$(document).ready(function () {
$.ajax({
url: 'http://d.yimg.com/aq/autoc?query=a®ion=US&lang=en-US',
dataType: 'jsonp',
jsonpCallback: 'YAHOO.util.ScriptNodeDataSource.callbacks'
});
});
YAHOO = {
util: {
ScriptNodeDataSource: {
callbacks: function(data) {
var sourceArray = $.map(data.ResultSet.Result, function(elem) {
$("#data").append( elem.name + ' -- ' + elem.symbol + '<br />');
});
}
}
}
};
</script>
<div id="data"> </div>
The above jquery seems to be working on stack overflow also. But on jsfiddle and on the sever where I have hosted my site this same jquery is not working.
It looks like something similar is happening on jsfiddle and on the server where I have hosted my site as on both the places it is giving me the same HTTP error (i.e 400 Bad request)
In the above link if I run my code I can see in developers console I am getting HTTP 400 error.
I have verified the GET url it looks fine to me in working and non-working scenario, not getting any idea where I should be looking in order to fix this. Any help regarding this will be appreciated.
Just found that even the jsfiddle is working when I tried opening my jsfiddle link via https://www.browserling.com(Its a website where you can test your website in different browsers)
But the same jsfiddle link is throwing HTTP 400 when I am trying to open it directly from my PC. Strange!! Is something wrong with my network or ISP :(