I have this code:
$.when(saveData()).done(alert('ok')).fail(alert('not ok'));
The result is that both ‘ok’ and ‘not ok’ being alerted.
Jquery docs says that .done() is equivalent for success and .fail equivalent for failure
(source: http://api.jquery.com/deferred.fail/)
My saveData() function:
function saveData()
{
var data_save = $('#eciform').serializeArray();
return $.ajax
({
type:"post",
url:"inputajax.cfm?mode=3",
data:data_save
});
}
How can it return ok and not ok at the same time? It should either be success or failure. Is it maybe because it only work with GET and not POST?
.done() and .fail() needs to be inside function()
or simply