There is a server and its ip address. On the server there is a file (cgi), which is accessed from the outside and it gives json accordingly, depending on the request. Addressing directly to the ip address from the browser line, all data is displayed correctly, but when there is a call from the script:

$.ajax({ type: "GET", url: 'http://<ip-address>/cgi-bin/api1.0/Tables?ip=localhost&port=9858&param=m', // data: myData, dataType: "text", success: function (data) { document.getElementById("info").innerHTML = data; }, error: function (data, status, errorThrown) { alert(status + errorThrown); } }); }); 

That throws out an error (the request reaches the server exactly), although the call to other servers, for example, by the domain name with the parameters goes correctly and the data is displayed correctly. What can be the problem?

  • Open the error console in your browser and look for js errors. Maybe the browser considers these cross-domain requests and the ban is triggered due to security policy. - Visman
  • writes that connection is close, is it possible to avoid either? - DZhuk

1 answer 1

You need to look at information about CORS and / or JSONP . Both of these technologies allow you to get data from another domain.