Skip to main content
February 12, 2009
Question

How to trap CF error inside AJAX function

  • February 12, 2009
  • 1 reply
  • 347 views
We are using Coldfusion MX7. I am calling a CFM file in AJAX function. I would like to know if there is a way to display the server-side error inside the AJAX function.

For example, the following is the function called after receiving response from the server (AJAX call).

function loginReply() {
if(http.readyState == 4){
var response = http.responseText;
if(response == 0){
// if login fails

alert(errorDetails); //Can I access the Coldfusion error details here?

} else {
document.getElementById('login_response').innerHTML = response;
}
}
}

Thanks
    This topic has been closed for replies.

    1 reply

    Inspiring
    February 12, 2009
    Hi Mahesh,

    Try Ray's "ColdFire" plugin through which you can view the all the ColdFusion debugging info (which occurs during your AJAX call), you can download it here

    http://coldfire.riaforge.org/

    P.S : It will work only in FireFox

    HTH
    February 12, 2009

    No, I am looking for something different.

    What I need is, display the error in a new javascript window.

    function cm_handleRegShutdownDays() {
    if(cm_xmlHttp.readyState == 4) {
    if(cm_xmlHttp.status == 200) {
    //success
    //some code
    }
    else {
    //error - display CF error page in a new window
    document.getElementById('myTempDiv').innerHTML = cm_xmlHttp.responseText; //displays error in a defined div
    }
    }
    }

    I would like to open a new window inside the 'else' condition and write 'responseText' to the new window and display to the user. Is it possible ?