Skip to content Skip to sidebar Skip to footer

How To Get Html Source Code By Usng Ajax Request

I want to get html source of particulate url by using ajax call, till I have done, url: 'http://google.com', type: 'GET', dataType: 'jsonp',

Solution 1:

The problem is that you are specifying dataType: "jsonp" and html is not json. Use dataType: "text" instead

Solution 2:

You can't use ajax to fetch some random content from anywhere in wild world of web... that is one of the reason for implementing Same Origin Policy for ajax requests...

Normal circumstances if a remote resource wants to make itself available across domain in browser environment then they will implement either jsonp or CORS... but both these techniques has to be implemented by the target resource...

In your case it is clear from the error that the remote resource is not implementing jsonp...

One possible solution is to make your web server act like a proxy... ie you sent a request to your server which will sent a request to the remote resource and gets back the remote content then sent it back to the client

Post a Comment for "How To Get Html Source Code By Usng Ajax Request"