locked
Writing AjaxFailed error message RRS feed

  • Question

  • User-127506019 posted

    In a web form application 2010, I  have the following ajax code:

       

        $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: document.location.pathname + "/GetStudentLetter",
                    data: "{ " + strData + " }",
                    dataType: "json",
                    success: function(data) {
                        LoadEditor(JSON.parse(data.d), milestone);
                    },
                    error: AjaxFailed
                });
    
            }

            }

    The line of code I am having a problem with is: error: AjaxFailed

    When this occurs in the application, an internal server error is generated. However I would like to know how to write better code so that I know what is really wrong with the application? Thus would you show me the following:

    1`. How to write better code so that I know what is really wrong?

    2. This application does not really have a log file to keep track of error messages that I am aware of. Thus can you tell where I can write the error message so that I know what the really error message is? I am guessing even to write the log file to the application server would be ok. Just let me know what you think are the best location is.

    3. For initially debugging before placing the error message in a file, how would I write an 'alert' display message so that I know what is wrong

    Friday, May 20, 2016 4:11 PM

Answers

  • User475983607 posted

    When you were talking about the console.log, I was thinking of a windows desktop console log since that is where my experience is at. You are talking about a console.log from JavaScript, correct?

    Yes, this is a web support forum.

    Is there some way the message from the console.log can be saved somewhere for a later reference? If so, can you show me where this log can be saved at and how to access the message that is saved?

    Right click and select Save As...

    I am asking this question since I am thinking of when the change would actually go into production. If an error occurs, I would like to be able to reference the error so that I can see what happened in production.

    I doubt it will work as expected considering the browser is on a client machine.  Consider using proper error handling on the server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 23, 2016 8:27 PM

All replies

  • User-1867989406 posted

    Please see the following link. This explains various options to handle these errors.

    http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages

    Friday, May 20, 2016 5:41 PM
  • User-127506019 posted

    Are there error messages that naturally occur? If so, where are these error messages to know what the real problem is. Is there also a way or links(s) to know what to do to solve the problem?

    Saturday, May 21, 2016 10:56 PM
  • User475983607 posted

    Someone else has the same exact issue, odd...

    http://forums.asp.net/t/2095573.aspx?jquery+json+post+call+size+too+large

    Replace this...

    error: AjaxFailed

    With 

    error: function(response) {
        console.log(response);
    }

    Use your browser's developer tools (press F12) to view the response in the console.  

    https://developer.chrome.com/devtools

    https://msdn.microsoft.com/en-us/library/dd565628(v=vs.85).aspx

    You can also look at the network tab for errors.  Lastly, use a proxy like Fiddler to view the HTML traffic.

    Sunday, May 22, 2016 11:23 AM
  • User-127506019 posted

    When you were talking about the console.log, I was thinking of a windows desktop console log since that is where my experience is at. You are talking about a console.log from JavaScript, correct?

    Is there some way the message from the console.log can be saved somewhere for a later reference? If so, can you show me where this log can be saved at and how to access the message that is saved?

    I am asking this question since I am thinking of when the change would actually go into production. If an error occurs, I would like to be able to reference the error so that I can see what happened in production.

    Monday, May 23, 2016 4:25 PM
  • User475983607 posted

    When you were talking about the console.log, I was thinking of a windows desktop console log since that is where my experience is at. You are talking about a console.log from JavaScript, correct?

    Yes, this is a web support forum.

    Is there some way the message from the console.log can be saved somewhere for a later reference? If so, can you show me where this log can be saved at and how to access the message that is saved?

    Right click and select Save As...

    I am asking this question since I am thinking of when the change would actually go into production. If an error occurs, I would like to be able to reference the error so that I can see what happened in production.

    I doubt it will work as expected considering the browser is on a client machine.  Consider using proper error handling on the server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 23, 2016 8:27 PM
  • User-127506019 posted

    Is there some way the message from the console.log can be saved somewhere for a later reference? If so, can you show me where this log can be saved at and how to access the message that is saved?

    Right click and select Save As.... Is there a way that the error message can automatically be saved instead of 'Right click and select Save As'. If so where would the error messages be written to? How do you access these error messages?

    I am asking that question since a windows desktop application, you can write these error messages to a log file.

    Tuesday, May 24, 2016 2:28 PM
  • User475983607 posted

    Is there some way the message from the console.log can be saved somewhere for a later reference? If so, can you show me where this log can be saved at and how to access the message that is saved?

    Right click the console and select Save As... Save the message wherever you like.

    Right click and select Save As.... Is there a way that the error message can automatically be saved instead of 'Right click and select Save As'. If so where would the error messages be written to? How do you access these error messages?

    Keep in mind the console is in your browser.  So you would need to write a browser plugin.

    I am asking that question since a windows desktop application, you can write these error messages to a log file.

    This is a browser based application not a window application.  Two very different platforms. 

    Tuesday, May 24, 2016 4:18 PM
  • User-127506019 posted

    what  browser plugin would you recommend that I use?

    Wednesday, May 25, 2016 3:00 AM