Unable to debug javascript in Chrome Developer Tools / Firebug

I have a simple javascript syntax error on one of my pages.

In the console from Chrome developer tools, I get the following message:

Uncaught SyntaxError: Unexpected token ( ... my_file.php(line 1799)

      

and

Failed to load resource: net::ERR_CACHE_MISS 

      

However, I cannot verify the source of the page. It just appears blank or won't load.

I went through the Resources tab in the script file and looked for the affected line. Line 1799 has a commented statement:

//location.reload();

      

It doesn't make sense, and this isn't the first time I've had a report in Chrome, only to find out that the problem was on a different line or file.

Firebug doesn't report anything, even though javascript doesn't work either.

What steps can I try to figure out what this error is?

I've already tried:

  • Refreshing the page. It is common knowledge that the script is only loaded after the second page load;
  • Checking the script file in the Source tab - it appears blank (no matter how many times I update);
  • Checking the script file in the Resources tab - the error is displayed in the comments. Line 1799 shows the commented statement;
  • Checking the script file in Firebug shows nothing. No errors are thrown in the script or in the console. And still, javascript doesn't work ...

Update : I fixed ERR_CACHE_MISS by clicking Ctrl+ F5(download and delete cache) as suggested in this thread .

However, the syntax error (unexpected closing braces) is still displayed. The location of the broken line depends on the refresh of each page, but they appear on lines that look normal.

Update # 2 : I fixed the problem. I had to check all my script lines and gradually fix syntax errors (which were away from the lines Chrome had outlined).

I still don't know why Firebug didn't tell me the faulty line or why Chrome DevTools pointed to the wrong one. This was the most difficult role.

+3


source to share


1 answer


(Copied from update # 2)

I fixed the problem. I had to check all of my script lines and gradually fix the syntax errors one by one (which were away from the lines Chrome had outlined).

While I was fixing different lines, the same line (which apparently looks correct) kept showing up with an error.



Then, after I corrected a certain line, the error from line 1799 was no longer reported.

I still don't know why Firebug didn't tell me the faulty line or why Chrome DevTools pointed to the wrong one. This was the most difficult role.

0


source







All Articles