JQuery ajax call error on remote servers

JQuery does not support Cross Site ajax queries, so if we call a function or method to get results from anoter domain then it wo’nt work.
As example below
// works fine as response.php is on same domain
$.get("response.php", function(data){
document.getElementById('myElement').innerHTML = data;
});
// will not work
$.get("http://pxlam.org/response.php", function(data){
//alert("Data Loaded: " + data);
document.getElementById('myElement').innerHTML = data;
});
so $.get, $.post, $.load etc do not work on remote servers.
Always use relative paths instead of absolute eg. /response.php instead of http://www.pxlam.org/redponse.php
Notes:
Cross-domain requests and dataType: “jsonp” requests do not support synchronous operation.
Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
Cross-domain requests and dataType: “jsonp” requests do not support synchronous operation.Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

Comments

Popular posts from this blog

111 Most Useful Websites on the Internet

How to call php functions inside smarty template directly

How to improve PHP web performance