0

is there any way to debug mistakes as misspelling URL in datatype as in the code:

$.ajax({beforeSend:function (XMLHttpRequest) {}, complete:function (XMLHttpRequest, textStatus) {}, 
                type: "POST", 
                data: ajaxPostData,
                dataType:"html", evalScripts:true, success:function (data, textStatus) {update(data)}, url: **HERE WAS A BUG**

PS. I use firebug and firephp

easyrider
  • 701
  • 3
  • 10
  • 20
  • Aren't you getting a 404 then? – Majid Fouladpour Jul 07 '11 at 14:48
  • 1
    Firebug has a **Net** tab. Enable it and you can monitor requests. – hakre Jul 07 '11 at 14:49
  • You can use $.ajax's `error` callback, check it at jquery $.ajax manual page. From there, you can alert or console.log the error. – Michael J.V. Jul 07 '11 at 14:50
  • @Majid Fouladpour no, my firebug console just gave me a html output – easyrider Jul 07 '11 at 14:50
  • And what makes you think the bug is part of `dataType` definition? Because they are on the same line? They buggy prop is the `url`, *not* `dataType`. – Majid Fouladpour Jul 07 '11 at 14:51
  • @Majid Fouladpour - your're right – easyrider Jul 07 '11 at 14:57
  • 1
    So, to *debug* that, you could use one of the methods suggested by @hakre or @Michael J.V. Of course when you *know* the url is wrong *debugging* does not make much sense, but when you are receiving wrong results and you don't know what is going on, one place to look for problems is FB's Net console to see what is returned, and another is utilizing the error callback to inspect values of internal variables. – Majid Fouladpour Jul 07 '11 at 15:04
  • @Majid Fouladpour Any example how to use .ajaxError() or error callback to debug the request? Net tab hasn't gave more info than FB console - just html output. – easyrider Jul 07 '11 at 15:13
  • 2
    http://stackoverflow.com/questions/3642348/jquery-ajax-error-callback and http://api.jquery.com/ajaxError/ – Majid Fouladpour Jul 07 '11 at 15:18

0 Answers0