How to mock AJAX call with NSURLProtocol?
问题 I have UIWebview that makes AJAX calls to external services. When offline i need to catch theses requests and return local json. I implemented a NSURLProtocol and i manage to catch the AJAX request, the problem is jquery always return a 0 error code : $.ajax({ url: url, dataType: 'json', contentType: "application/json", success: function(jsonData){ alert("success :"); }, error: function (request, status, error) { alert("failure :" + request.status ); } }); I always get a request.status = 0 To