Hi,
I have got a test page to use Ajax to make a http 'delete' request to a server. The following JS code works as intended in IE7, but it does not work in Firefox (unless I make the ajax call asynchronous).
In Firefox, unless async is false, the error callback gets triggered with status of 0.
- Can anyone assist in explaining why this is apparently working in Firefox if the call is synchronous?
- In the context of this page, a synchronous call is not a bad thing, however I have read that this should be avoided as this would effectively freeze the browser window until the response had returned. Is there an alternative solution anyone can suggest?
The relevant code is below:-
<script src="${url.context}/scripts/jquery-1.3.2.min.js"></script>
<SCRIPT LANGUAGE="JavaScript">
jQuery.noConflict();
function deleteImage(nodeParam) {
alert('hello');
var options = {
type: 'DELETE',
async: false,
url: '${url.context}/service/api/asset/delete?alf_ticket=${session.ticket}'+'&format=text'+'&'+nodeParam,
dataType: 'json',
success: function(data, textStatus) {
jQuery('#result-div').html('');
if (data['ok'] == true) {
//jQuery('#result-div').html('Delete successful using parameter - ' + nodeParam);
alert("Delete successful" );
} else {
alert( "Response 'ok' set to 'false' on success callback!" );
jQuery('#result-div').html('Delete failed!');
}
},
error: function (request, textStatus, errorThrown) {
//jQuery('#result-div').html('Delete failed!');
alert("Delete Failed");
alert(request.status);
//alert("Error callback triggered, request failed with status: " + request.status + ' ' + request.responseText);
}
};
jQuery.ajax(options);
}
// End -->
</script>
Thanks J