0

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&region=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)

My jsfiddle link

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 :(

mSatyam
  • 531
  • 7
  • 25
  • 1
    I see results from your jsfiddle - don't see bad request. – Davie Brown Apr 04 '16 at 20:01
  • 400, bad request indicates that the server doesn't like your request. Maybe the url is incorrect after all (missing a certain parameter, or having a wrong value), or the request requires some headers or cookies being set. The request is being performed. You know that. So I'd check the documentation of the API your are using and try to find out in which scenarios it might give such an error code. – GolezTrol Apr 04 '16 at 20:02
  • Strange @DavieBrown from your end the same jsfiddle is working. but for me its not. :( – mSatyam Apr 04 '16 at 20:04
  • Which browser are you using? I'm using the latest version of Chrome. – Davie Brown Apr 04 '16 at 20:05
  • I tried with google chrome Version 49.0.2623.108 (64-bit) on linux l think its latest only. Also on same browser I am able to execute this jquery locally just from jsfiddle it is not working – mSatyam Apr 04 '16 at 20:07
  • Just executed the same jquery from https://www.browserling.com and it works. Just when I am directly trying to open it in jsfiddle then it is not working...how strange Is something wrong with my ISP or my PC – mSatyam Apr 04 '16 at 21:20
  • I tried running the same jsfiddle via proxy and it works..it just not works if I open it from any PC at my home – mSatyam Apr 05 '16 at 08:41

0 Answers0