Jquery getJSON to external PHP page

Posted by Pmarcoen on Stack Overflow See other posts from Stack Overflow or by Pmarcoen
Published on 2009-04-26T14:17:02Z Indexed on 2010/03/21 3:31 UTC
Read the original article Hit count: 363

Filed under:
|
|
|
|

I've been trying to make an ajax request to an external server. I've learned so far that I need to use getJSON to do this because of security reasons ?

Now, I can't seem to make a simple call to an external page. I've tried to simplify it down as much as I can but it's still not working. I have 2 files, test.html & test.php

my test.html makes a call like this, to localhost for testing :

    $.getJSON("http://localhost/OutVoice/services/test.php", function(json){
	alert("JSON Data: " + json);
});

and I want my test.php to return a simple 'test' :

$results = "test";
echo json_encode($results);

I'm probably making some incredible rookie mistake but I can't seem to figure it out. Also, if this works, how can I send data to my test.php page, like you would do like test.php?id=15 ?


The test.html page is calling the test.php page on localhost, same directory I don't get any errors, just no alert ..

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON