954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to check if URL exists..?

Hi guys.,

I have a textbox for entering URL. I validate that URL using regular expression. Now the problem is, How do i know whether the entered URL is exist or not.?

For example, if user enter "http://www.daniweb.cam" rather entering "http://www.daniweb.com", how do i intimate them that the entered url is not valid.?

Is it possible..?

Please kindly advise me....

Thanks,
DragonBaki.

Dragonbaki
Junior Poster
130 posts since Oct 2010
Reputation Points: 15
Solved Threads: 21
 

Dragonbaki,

I've not needed to do this but here are my thoughts .....

The most efficient way would be to make what's called a "HEAD request" and the easiest way I can find to do this is a jQuery plugin:
http://plugins.jquery.com/project/jqHead

As written, I'm pretty certain this plugin won't handle cross-domain requests, which may be an issue for you.

For cross-domain, you have a couple of basic options:Flash-proxy: I like FlXHR . With a little thought, this should be usable with a modified jqHead plugin, because core jquery allows you to specify your own xmlhttp object in a $.ajax request (see this and jquery API).
PHP Proxy: Build you own or find a script on the web. With this approach, javascript will make its request to a same-domain php script (ie on same server as the current web page); the script will use php's capability to make a request to another domain (I'm no expert here - see PHP manual).
Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: