I have the following getJSON request:
$.getJSON(url + "&callback=?", {
postData: myText
}, function(data) {
alert('data : ' + data);
});
For my testing I have an applicatoin running on "localhost:8080" and I am performing this getJSON from here in a JSP, and an HTTP Server running on "localhost:8090".
The URL I am using in my getJSON above, is the URL of this HTTP Server, i.e. "http://localhost:8090/json". This is available. On this URL, I am outputting a JSON based string.
So.. in my getJSON, I want to get this data back from what is being displayed on the HTTP Server page.
But it doesn't work.
This is my HTTP Server code:
public void RunHttpServerStart() {
HttpServer server = null;
try
{
HttpJsonHandler handler = new HttpJsonHandler();
server = HttpServer.create(new InetSocketAddress(8090), 10);
server.createContext("/json", handler); // The handler holds my JSON string being output
server.setExecutor(null); // creates a default executor
server.start();
System.out.println("Server is started");
while(handler.shutdown == false) { Thread.sleep(1000); }
System.out.println("Stopping server");
}
catch(Exception ex) { System.out.println(ex.getMessage());}
finally {
if(server != null)
server.stop(0);
}
}
I have implemented the example from JQUERY's website for getJSON with the images from flicker, but how do I get this string data back in the getJSON call?