Here I am trying to request data from REST API data and present in a webpage using JQuery.
I am making 3 different request which approximately takes 200ms, 300 ms, 7000 ms times for the response. Here two call methods are being called out of 3, I don’t understand why 3rd one is not being called. When debug using Firebug tool, response is getting from server.
When the order of below function changes the behavior is also getting changed. any of one or two callback methods are being called.
Please help me in solve this issue.
$.getJSON(
"http://115.111.168.221:8080/AnalysisWebService/getDataFromSocialMedia?searchString=wellpoint&startDate=2012-08-01&endDate=2012-08-04&method=getAnalysisRange",
function(json) {
}
$(function () {
$.getJSON(
"http://115.111.168.221:8080/AnalysisWebService/getDataFromSocialMedia?searchString=wellpoint&source=facebook,twitter&searchFrom=socialmention&method=getTodayAnalysis",
function(json) {
}
}
);
);
$(function () {
$.getJSON(
"http://115.111.168.221:8080/AnalysisWebService/getDataFromSocialMedia?searchString=wellpoint&source=facebook,twitter&searchFrom=socialmention&method=getCurrentAnalysis",
function(json) {
}
}
);
);
Try this:
You don’t need to wrap them in anything else as the DOM doesn’t have to be ready in order for you to fire off some requests.
Better yet, do something like this for more readability:
edit: I’ve attached error handlers as well, and removed the ? from the url.