1

I have following snippet of code

   $.ajax({
            method  :   "GET",
            url     :   'http://projectstorehouse.com/travelnews/index.html',
            data    :   "",
            success :   function(){
                            alert("Hello");
                        },
            error   :   function(jqXHR, status, error){
                        if (jqXHR.status === 0) {
                            alert('Not connected.\nPlease verify your network connection.');
                        } else if (jqXHR.status == 404) {
                            alert ('The requested page not found. [404]');
                        } else if (jqXHR.status == 500) {
                            alert ('Internal Server Error [500].');
                        } else if (exception === 'parsererror') {
                            alert ('Requested JSON parse failed.');
                        } else if (exception === 'timeout') {
                            alert ('Time out error.');
                        } else if (exception === 'abort') {
                            alert ('Ajax request aborted.');
                        } else {
                            alert ('Uncaught Error.\n' + jqXHR.responseText);
                        }
            }
        });

and could not figure out problem associated with it; the message displayed with this is jqXHR.status==0. Url is reachable http://projectstorehouse.com/travelnews/index.html

Can anybody tell me where I am wrong;

Veshraj Joshi
  • 3,128
  • 2
  • 20
  • 35
  • Check your browser console to see the error.... you might have a message like `XMLHttpRequest cannot load http://projectstorehouse.com/travelnews/index.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access.` – Arun P Johny Jan 07 '16 at 07:41
  • thanks, unfortunately no error in console regarding this. – Veshraj Joshi Jan 07 '16 at 07:43
  • Yeah, getting exactly same error with no good reason. In fact, it seems the code is executing OK, except for the error return. – BlooSki Nov 08 '17 at 20:48

0 Answers0