-1

My Ajax response is an HTML code how can I save these values in the ajax response for to search values on it? I'm trying to get it in the complete function but I just get

complete: function(e,t,){
                console.log(t);
               console.log(e);
           }

Object { readyState: 0, getResponseHeader: getResponseHeader(), getAllResponseHeaders: getAllResponseHeaders(), setRequestHeader: setRequestHeader(), ...

Also I can not use success function because my response is HTML which is throwing a CORS error and status code 0 in the response by the HTML contains the success or error msg and that's why I what to get it, and why to do it in the complete.

UserEsp
  • 415
  • 1
  • 7
  • 29
  • 1
    [`complete`](https://api.jquery.com/jquery.ajax/): _"A function to be called when the request finishes (after success and error callbacks are executed). **The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request**"_ – Andreas Nov 08 '19 at 16:31
  • 2
    Use `success: ...` instead (and [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call)) – Andreas Nov 08 '19 at 16:32
  • I guess I should be more specific I can not use success function because my response is HTML which is throwing a CORS error and status code 0 in the response by the HTML contains the success or error msg and that's why Ii what to get it, and why to do it in the complete. – UserEsp Nov 08 '19 at 16:48
  • 4
    If you have problems with CORS then neither `complete` nor `success` nor anything else on the client will help you. Just search for CORS here on SO – Andreas Nov 08 '19 at 16:50

1 Answers1

2

A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified;

success: function(response){
    alert(response);
}
demkovych
  • 7,827
  • 3
  • 19
  • 25