Note that there are some explanatory texts on larger screens.

plurals
  1. POCross Domain URL in jQuery
    text
    copied!<p>I have made a very simple index.php code as following</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/httpGet.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery.mobile.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="string" type="text"/&gt; &lt;input id="button" type= "button" value="Check" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In this HTML code we get a number fro user and call httpgGet.js file. And the httpGet.js is :</p> <pre><code>$('#button').click(function() { var string = $('#string').val(); $.post('http://...../isprime.php',{number: string},function(data){ alert(data); } } </code></pre> <p>we send the user number to a isprime.php file where it checks if a user number is a prime number or not. When I say $.post('php/isprime.php',.....) it works very well, but when I want to call the isprime.php from another computer, it does not work.</p> <p>I mean $.post('192.168.1.1/test/isprime.php'....) gives me a not found error.</p> <p>The file exists and I am able to run the code using direct call from browser. When I type in browser 192.168.1.1/test/isprime.php the file is reachable, but from the js file, it fails. Obviously, I can ping 192.168.1.1 too. I checked the code even with FireBug and no way thorough.</p> <p>I searched a lot and came a cross that Browsers do not allow cross domain call (for security purpose, I guess), but I cannot find a solution to get rid of this problem. There are something about YQL (which is a query language and I don't know if I can use it or not). Also I saw something about cULR but I am not sure if that works too.</p> <p>Kindly help. I really need it. thank u very much.</p>
 

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