<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 5:02 PM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi guys,<div><br></div><div>It happens to me quite frequently that I have some issue in an AJAX calls. On Chrome, I see:</div><div><br></div><div><div>Uncaught SyntaxError: Unexpected token $ in JSON at position 0</div><div>    at JSON.parse (<anonymous>)</div><div>    at Function.n.parseJSON (jQuery.js:4)</div><div>    at HTMLDocument.<anonymous> (reps?_s=YZ0L_G1AYPiERSfd&_k=<wbr>lD9O_xh3oh59qMMq:453)</div><div>    at HTMLDocument.dispatch (jQuery.js:3)</div><div>    at HTMLDocument.r.handle (jQuery.js:3)</div><div>    at Object.trigger (jQuery.js:3)</div><div>    at x (jQuery.js:4)</div><div>    at XMLHttpRequest.b (jQuery.js:4)</div></div><div><br></div><div>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:</div><div><br></div><div>$("#id174").replaceWith("<div class=\"companyReportMainDiv\" id=\"id232\"><div id=\"popupContainer9358488\" class=\"popupContainer\"></<wbr>div><script<br></div><div>..........</div><div>)</div><div><br></div></div></blockquote><div><br></div><div><br></div><div>OK, the JSON failure was due to my AJAX error handler, which was trying to do (see bold part)</div><div><div> </div><div>                var requestResponse = {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>    url: settings.url,</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">               </span>    method: settings.type,</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>    data: settings.data,</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">             </span>    httpStatus: jqxhr.status,</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>    error: exception || jqxhr.statusText,</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>    data: settings.data</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>  };</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">         </span>responseText = jqxhr.responseText;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">             </span>responseText.replace(/[\\"'']/g, ''\\$&'').replace(/\u0000/g, ''\\0''); </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">             </span>console.error(requestResponse);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span><b>jsonValue = jQuery.parseJSON(responseText);</b><br></div><div><br></div></div><div>I am now printint to console the requestResponse that was in this ajax error handler, and this is what I get:</div><div><br></div><div><ol class="gmail-tree-outline gmail-source-code gmail-object-properties-section" style="min-width:0px;min-height:0px;box-sizing:border-box;font-family:menlo,monospace;white-space:pre-wrap;font-size:11px;padding:0px;margin:0px;display:flex;list-style-type:none;color:rgb(33,33,33)"><li class="gmail-parent gmail-object-properties-section-root-element expanded" style="min-width:0px;min-height:16px;box-sizing:border-box;display:flex;text-overflow:ellipsis;white-space:nowrap"><span style="min-width:0px;min-height:0px;box-sizing:border-box">Object<span class="gmail-object-state-note gmail-info-note" style="min-width:0px;min-height:0px;box-sizing:border-box;display:inline-block;width:11px;height:11px;color:white;text-align:center;border-radius:3px;line-height:13px;margin:0px 6px;font-size:9px;background-color:rgb(179,203,247)"></span></span></li><ol class="gmail-children expanded" style="min-width:0px;min-height:0px;box-sizing:border-box;list-style-type:none;padding-left:12px"><li style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(136,19,145)">data</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-undefined" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(128,128,128)">undefined</span></li><li class="gmail-parent expanded" style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(136,19,145)">error</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-error" style="min-width:0px;min-height:0px;box-sizing:border-box">SyntaxError: Unexpected token , at eval (<anonymous>) at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a> at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627</a>) at n.fn.init.domManip (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515</a>) at n.fn.init.replaceWith (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650</a>) at eval (eval at <anonymous> (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>), <anonymous>:1:13) at eval (<anonymous>) at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a> at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627</a>) at text script (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788</a>)</span></li><ol class="gmail-children expanded" style="min-width:0px;min-height:0px;box-sizing:border-box;list-style-type:none;padding-left:12px"><li style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name gmail-object-properties-section-dimmed" style="min-width:0px;min-height:0px;box-sizing:border-box;opacity:0.6;color:rgb(136,19,145)">message</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-string" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(196,26,22);white-space:pre;unicode-bidi:-webkit-isolate">"Unexpected token ,"</span></li><li class="gmail-" style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name gmail-object-properties-section-dimmed" style="min-width:0px;min-height:0px;box-sizing:border-box;opacity:0.6;color:rgb(136,19,145)">stack</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-string" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(196,26,22);white-space:pre;unicode-bidi:-webkit-isolate">"SyntaxError: Unexpected token ,↵    at eval (<anonymous>)↵    at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>↵    at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)%E2%86%B5">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)↵</a>    at n.fn.init.domManip (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515)%E2%86%B5">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515)↵</a>    at n.fn.init.replaceWith (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650)%E2%86%B5">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650)↵</a>    at eval (eval at <anonymous> (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>), <anonymous>:1:13)↵    at eval (<anonymous>)↵    at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>↵    at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)%E2%86%B5">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627)↵</a>    at text script (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788</a>)"</span></li><li class="gmail-parent" style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name gmail-object-properties-section-dimmed" style="min-width:0px;min-height:0px;box-sizing:border-box;opacity:0.6;color:rgb(136,19,145)">__proto__</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-object" style="min-width:0px;min-height:0px;box-sizing:border-box;vertical-align:baseline;color:inherit;display:inline-block">Error</span></li></ol><li style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(136,19,145)">httpStatus</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-number" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(28,0,207)">200</span></li><li style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(136,19,145)">method</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-string" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(196,26,22);white-space:pre;unicode-bidi:-webkit-isolate">"GET"</span></li><li style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(136,19,145)">url</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-string" style="min-width:0px;min-height:0px;box-sizing:border-box;color:rgb(196,26,22);white-space:pre;unicode-bidi:-webkit-isolate">"/reps?_s=YZ0L_G1AYPiERSfd&_k=-szkZv0x3mvWhG7t&193&203=VALE&206=1&207=&216=&221=&_=1486757530835"</span></li><li class="gmail-parent" style="min-width:0px;min-height:16px;box-sizing:border-box;text-overflow:ellipsis;white-space:nowrap;display:flex"><span class="gmail-name gmail-object-properties-section-dimmed" style="min-width:0px;min-height:0px;box-sizing:border-box;opacity:0.6;color:rgb(136,19,145)">__proto__</span><span class="gmail-object-properties-section-separator" style="min-width:0px;min-height:0px;box-sizing:border-box;padding-right:5px">:</span><span class="gmail-value gmail-object-value-object" style="min-width:0px;min-height:0px;box-sizing:border-box;vertical-align:baseline;color:inherit;display:inline-block">Object</span></li></ol></ol></div><div><br></div><div><br></div><div><br></div><div><span style="font-family:menlo,monospace;font-size:11px;white-space:pre">SyntaxError: Unexpected token ,
    at eval (<anonymous>)
    at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>
    at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627</a>)
    at n.fn.init.domManip (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:22515</a>)
    at n.fn.init.replaceWith (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:3:21650</a>)
    at eval (eval at <anonymous> (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>), <anonymous>:1:13)
    at eval (<anonymous>)
    at <a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2616</a>
    at Function.globalEval (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:2:2627</a>)
    at text script (<a href="https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788">https://debrisdemo.quuve.com/JQDeploymentLibrary/jQuery.js:4:26788</a>)</span><br></div><div><br></div><div><br></div><div>I don't understand what is going on. Any ideas?</div><div><br></div><div>Thanks in advance</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Chrome shows me that with a red underline like if that would have an error, but such JS is correct. </div><div><br></div><div>Any idea how can I know what is going on? </div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div><div><br></div>-- <br><div class="gmail-m_-7009639393465748942gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.<wbr>com</a><br></div>
</div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br></div>
</div></div>