title: $.ajax error function is not working
body: <p>I'm working on some existing code. I have the following code:</p>
  
  <pre><code>$.ajax({
          type: "get",
          url: url ,
          dataType: "jsonp",
          cache: "false",
          jsonpCallback: "onJSONPLoad",
          success: function(json){
                 alert('hi!');
                 //perform operation
          },
          error: function() {
            alert('Error occurs!');
         }
  });
  </code></pre>
  
  <p>Now when I'm passing valid <code>url</code> it works fine. But when I'm passing invalid <code>url</code> it should through an error alert. But the script is not throwing any error alert. Basically I want validate the <code>url</code> parameter or it is failing?  Please help me to find-out the error in my code or suggest me else way to achieve. I have checked the following links but not able to solve my problem:<br/></p>
  
  <p><a href="https://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages">jQuery Ajax error handling, show custom exception messages</a> <br/>
  <a href="https://stackoverflow.com/questions/6792878/jquery-ajax-error-function">jQuery ajax error function</a>,
  <a href="https://stackoverflow.com/questions/8918248/ajax-success-and-error-function-failure/17549074#17549074">Ajax Success and Error function failure</a></p>
  
  <p><strong>UPDATE:</strong>
  I have added below code to log the jquery console log.</p>
  
  <pre><code>  @Override
              public boolean onConsoleMessage(ConsoleMessage cm) {
                  Log.d("web chrome client", cm.message() + " -- From line "
                  + cm.lineNumber() + " of "
                  + cm.sourceId() );
                  return true;
              }
  </code></pre>
  
  <p>Identified the following error:
  <code>XMLHttpRequest cannot load file:///android_asset/xxxx/new_source.json?callback=onJSONPLoad. Origin null is not allowed by Access-Control-Allow-Origin. -- From line 1 of null</code> <br/></p>
  
  <p>Adding the following code, app is running successfully.</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt;= VERSION_CODES.JELLY_BEAN) {
    webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
  }
  </code></pre>
  
  <p>So, basically this is happening  as the url is not accessible by the jquery.<br/> 
  Thanks every body for helping me.</p>