Reputation: 9759
I know this will probably lead to a security breach, but is there a way in JavaScript to check the validity of a URL? This has to be done in the client, because I need to check whether the URL is accessible from it. Internal/external network differences apply.
I have tried to use jQuery.ajax()
, but it won't work with remote servers, and also JSONP, but I can't expect a JSON response. In fact, I have to test any sorts of URLs, not only valid XML or JSON.
Basically, I need to check for a valid statusCode = 200
or similar, if possible.
Upvotes: 1
Views: 752
Reputation: 9759
Well, it seems it's indeed not possible, probably due to security issues.
The resolution to this in my case was to create a JSONP response in another server, and the script would simply make a request to it (JSONP allows cross-domain requests).
Thanks to all.
Upvotes: 1