I try to make a jQuery.ajax call:
jQuery("#search_form").live("submit", function() {
search_nr = jQuery("#search_input").val();
jQuery.ajax({
url: '/modules/mod_findarticle/process.php',
data: "search_nr="+search_nr,
async: true,
'success': function(data) {
alert(data);
},
'error': function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.status+", " + jqXHR.statusText+", "+textStatus+", "+errorThrown);
}
});
});
In return i always get an alert with "0, error, error," message. Everything's fine with async=false. I know that with asynchronous call the script finish work before any actual data is recieved but what can be done to avoid this?
.liveis deprecated. You should use.on.alert(jqXHR.status+", " + jqXHR.statusText+", "+textStatus+", "+errorThrown);which shows 0, error, error, 2. Indeed, async is enanled by default. If I remove async=true at all, nothing changes. 3. thanks for the comment, but i doubt that the problem is related to .live() 4. I tried to add the dataType parameter to the .ajax call, setting it to "html" or "json" with no effect.