Click here to Skip to main content
15,614,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
why My following jquery function always execute Error block of alert but is available..

<script type="text/javascript">
  $(document).ready(function() {
  function checkIparcel() {
      type: 'GET',
      url: '',
      timeout: 15000,
      success: function(data) { alert('Connected to i-parcel.'); },
      error: function(XMLHttpRequest, textStatus, errorThrown)
      { alert('Error:\r\n' + textStatus); }
</script> site is available.
Still control goes into error block please help..
Please check my answer.

Is your page located on the same domain (i.e. on')?
If not, you can't just directly access it with $.ajax due to cross domain restrictions. (If there is an REST API, you might want to use JSONP, or perhaps use CORS for moderm browsers).[^][^][^]
Share this answer
k@ran 29-Jan-13 7:00am    
No I am using above code in my local pc.
Vyacheslav Voronenko 29-Jan-13 7:01am    
Thus, it will not work due to reasons specified above.
I tested this and it is working fine.
Going to success and giving alert 'Connected to i-parcel.'.

Check Live Demo.[^]
Share this answer
Update - It is also working on my local. If you need, then I can share you the file to download.
k@ran 29-Jan-13 7:12am    
please share..
k@ran 29-Jan-13 7:17am    
@Tadit Dash : Please share it, or mail me at
Shared - Mrinal_Test_jQuery_Ajax.
Please download and see.
May be your connection is taking time to connect.
So, try to increase the timeout value above 15000.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900