ajax success not successful

Oburi

New Member
I'm not sure what's happening here, but I'm not able to get a successful response. Here is my code:\[code\]function sendCallAjaxUsingJson(theUrl, theData, successCallbackFunction, timeoutCallbackFunction, otherErrorCallback, timeoutValueMilli){ var successFn = successCallbackFunction; var timeoutFn = timeoutCallbackFunction; var otherFn = otherErrorCallback; if(!(typeof successFn === 'function') || !(typeof timeoutFn === 'function') || !(typeof otherFn === 'function')) return false;$.ajax({ type: "POST", url: theUrl, timeout:timeoutValueMilli, dataType: 'json', data: { json: JSON.stringify(theData) }, success:successFn, error: function(x, t, m) { if(t==="timeout") { timeoutFn(); } else { otherFn(); } } });}\[/code\]On the server side I'm using PHP. I can trigger the timeout function by making the PHP script \[code\]sleep\[/code\] for 2 sec and using a 1000 millisec timeout. The Timeout function executes correctly. However, when I just echo a string from the script, I don't get the success function to fire. Instead, the \[code\]otherFn\[/code\] fires from above. Using Firebug, I can see that the string I echo'ed from the script was successfully received.So why is it calling the error script? It appears that everything is successful, but it fires the error function.
 
Back
Top