Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Browsers do not allow you to request resources from another domain (images and script files are the notable exceptions to this rule). </p> <p>This can be solved in few ways.</p> <ol> <li><p>First way is by using JSONP call (the current standard for cross-domain access), and yes JSONP only allows GET. But this is just a part of the solution. Server side also needs to be changed to allow cross domain calls.</p> <p>In order to be able to access an external resource from javascript. The remote resource MUST include access-control-allow-origin in the response header. If you have control over that resource, you need to add this response header to * (or your domain if you want a more restricted access control). Of course this part od solution will depent on your server side architecture (PHP, ASP.NET, JSP ...)</p> <p>Here's a PHP/jQuery solution described in details: <a href="http://www.fbloggs.com/2010/07/09/how-to-access-cross-domain-data-with-ajax-using-jsonp-jquery-and-php/" rel="nofollow">http://www.fbloggs.com/2010/07/09/how-to-access-cross-domain-data-with-ajax-using-jsonp-jquery-and-php/</a></p> <p>Also return result must be wrapped into jsonpCallback function, so return should look liek this:</p> <pre><code>someFunction("{...}"); </code></pre> <p><strong>someFunction</strong> is the name of callback function and classic JSON is {....}. You can see, it is wrapped with <strong>someFunction(</strong>.</p> <p>jQuery side should look like this:</p> <pre><code>$.ajax({url: server_url, type: "GET", data: save_data, dataType: "jsonp", jsonpCallback: 'successCallback', async: true, beforeSend: function() { }, complete: function() { }, success: function (result) { }, error: function (request,error) { }, successCallback:function(){ } }); </code></pre> <p><a href="http://devlog.info/2010/03/10/cross-domain-ajax/" rel="nofollow">http://devlog.info/2010/03/10/cross-domain-ajax/</a></p></li> <li><p>Or a Proxy solution. I am not going to write about it because I never tested it. Use this solution only if you don't have access to server side code: </p> <p><a href="http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html" rel="nofollow">http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html</a> <a href="http://developer.yahoo.com/javascript/howto-proxy.html" rel="nofollow">http://developer.yahoo.com/javascript/howto-proxy.html</a></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload