I have a very simple AJAX request with jQuery and PHP. This is my code
var request = $.ajax({
method: "POST",
url: "Url.php",
data: { param: valueParam },
dataType: "html"
});
request.done(function(html) {
alert('Hello');
});
The code works perfect in Firefox 38.0.5 but not works in Chrome 43.0.2357.124m.
The problem in Chrome is the follow: the "Url.php" returns a pair name-value. If it returns a value distinct than null, then the alert is not displayed (and there isn't any error in the console). But if the url return a null value, the alert is displayed. I tried ctrl+F5 but not works.
In Firefox works good in both cases.
Thanks!
The problem is when I was firing the ajax request. I was doing it in "onchange" (of a input text with jQuery autocomplete) jQuery event. When I select an item of the list of autocomplete, the onchange() event is not raised in Chrome (yes in Firefox).
So I fire the ajax request in jQuery "focusout" event and works in Chrome and Firefox.
Does fail function return something?
request.done(function( msg ) {
console.log(msg);
});
request.fail(function( jqXHR, textStatus ) {
console.log("Request failed: "+textStatus);
});