[Seaside] How can I debug ajax errors?

Mariano Martinez Peck marianopeck at gmail.com
Fri Feb 10 20:29:28 UTC 2017


On Fri, Feb 10, 2017 at 5:02 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

> Hi guys,
>
> It happens to me quite frequently that I have some issue in an AJAX calls.
> On Chrome, I see:
>
> Uncaught SyntaxError: Unexpected token $ in JSON at position 0
>     at JSON.parse (<anonymous>)
>     at Function.n.parseJSON (jQuery.js:4)
>     at HTMLDocument.<anonymous> (reps?_s=YZ0L_G1AYPiERSfd&_k=
> lD9O_xh3oh59qMMq:453)
>     at HTMLDocument.dispatch (jQuery.js:3)
>     at HTMLDocument.r.handle (jQuery.js:3)
>     at Object.trigger (jQuery.js:3)
>     at x (jQuery.js:4)
>     at XMLHttpRequest.b (jQuery.js:4)
>
> But there is no way for me to know what triggered that at Seaside level.
> If I inspect the "VM2043:1" kind of link in the Chrome console, I get to
> the script generated by my ajax which is something like:
>
> $("#id174").replaceWith("<div class=\"companyReportMainDiv\"
> id=\"id232\"><div id=\"popupContainer9358488\" class=\"popupContainer\"></
> div><script
> ..........
> )
>
>

OK, the JSON failure was due to my AJAX error handler, which was trying to
do (see bold part)

                var requestResponse = {
   url: settings.url,
   method: settings.type,
   data: settings.data,
   httpStatus: jqxhr.status,
   error: exception || jqxhr.statusText,
   data: settings.data
 };

responseText = jqxhr.responseText;
responseText.replace(/[\\"'']/g, ''\\$&'').replace(/\u0000/g, ''\\0'');
console.error(requestResponse);
*jsonValue = jQuery.parseJSON(responseText);*

I am now printint to console the requestResponse that was in this ajax
error handler, and this is what I get:


   1. Object
      1. data:undefined
      2. error:SyntaxError: Unexpected token , at eval (<anonymous>) at
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616 at
      Function.globalEval (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627) at
      n.fn.init.domManip (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515)
      at n.fn.init.replaceWith (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650)
      at eval (eval at <anonymous> (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616),
      <anonymous>:1:13) at eval (<anonymous>) at
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616 at
      Function.globalEval (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627) at
      text script (
      https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788)
         1. message:"Unexpected token ,"
         2. stack:"SyntaxError: Unexpected token ,↵ at eval (<anonymous>)↵
         at
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616↵
         at Function.globalEval (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)↵
         at n.fn.init.domManip (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515)↵
         at n.fn.init.replaceWith (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650)↵
         at eval (eval at <anonymous> (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616),
         <anonymous>:1:13)↵ at eval (<anonymous>)↵ at
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616↵
         at Function.globalEval (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)↵
         at text script (
         https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788
         )"
         3. __proto__:Error
      3. httpStatus:200
      4. method:"GET"
      5. url:
      "/reps?_s=YZ0L_G1AYPiERSfd&_k=-szkZv0x3mvWhG7t&193&203=VALE&206=1&207=&216=&221=&_=1486757530835"
      6. __proto__:Object




SyntaxError: Unexpected token , at eval (<anonymous>) at
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616 at
Function.globalEval (
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627) at
n.fn.init.domManip (
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515) at
n.fn.init.replaceWith (
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650) at eval
(eval at <anonymous> (
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616),
<anonymous>:1:13) at eval (<anonymous>) at
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616 at
Function.globalEval (
https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627) at text
script (https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788)


I don't understand what is going on. Any ideas?

Thanks in advance



> Chrome shows me that with a red underline like if that would have an
> error, but such JS is correct.
>
> Any idea how can I know what is going on?
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>



-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170210/c60e2e42/attachment-0001.html>


More information about the seaside mailing list