This time, I am going to explain about How to call Remote URL in jQuery Ajax?. Recently I am working on an android application and got a parse error when trying to execute remote url in ajax.
I am using remote URL to call web service which posts data to remote URL and returns a JSON response contains data and I have used jsonp for requesting the JSON data because AJAX doesn’t support cross domain
calls by default because of security reasons.
JSONP is the light weight method to request data from a server to a different domain.JSONP is useful for cross domain issue and calls remote/external URL request.
Let’s view following code:
Problem & solution:
Here I have pass dataType as jsonp and important is to pass &callback=
into url otherwise your code will not work.you will not get proper response.If &callback is missing, you will get parse error
or error status = 0
.
It’s a wrap!.This is the today’s quick tip! I’m hoping that you’ve found this technique useful.
Further Reading:
To use Ajax in WordPress
Solution: Internet connection issue on AndroidEmulator
To read JSON data with jQuery
As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (4)