I've been building a set of mostly HTML and JS functions using Jquery and ajax with PHP backend. For some reason, a page that didn't used to have problems suddenly doesn't load. When I check the document inspector, I find that the code just... stops. Before it ended on a line of HTML. Today, it's in the middle of some JS code (around line 1364).
I had a chunk of JS code commented out that I removed from the code and suddenly it worked... until I brought in some more code from another file and it suddenly stopped again.
What makes HTML code suddenly stop? It's driving me nuts! My code became very fragile.
Check these :
1.does JavaScript has syntax error? (check inspector console)
2.does your PHP has syntax or logic error?(Ex:In CentOS 7,type command#tail -f /var/log/httpd/error_log)
Trouble Shoot
Sometime js do not report error even the program stop.
So, you can add some console.log('test') in your code to find out which line cause js exec stop.
I had to remove most of my code and reinsert it one section at a time. I found a missing tag though I still don't understand why the code responded in such a weird way.
Related
I followed this tutorial on how to get my Javascript changes to save, and my changes are indeed "saved", in that I can see the changes when I reload the website. Despite this, the saved changes are not actually run, and do not seem to even exist in the website's mind, since an error that had occurred on Line XYZ still does, despite the code on Line XYZ being shifted down.
I also saw something about the code not running if it was prettified. I cannot seem to unpretify it though, because the {} thing on the bottom left does not seem to change anything.
reolad the website will reload all js files, so your changes will be lost. If you insert a breakpoint in line 100, and change your code after this line, your change will be executed after you stash js file and resume executing.
This is the screenshot of my html page. this commented area is my issue.
Your problem starts with a couple of error's :)
Your Javascript crashes because it looks for a function that doesn't exist "$(...).fancybox()". This means that either you didn't include the fancybox library or that the file where you call in the function fancybox is loaded before the fancybox library is loaded in.
Next problem is that the images that are used in your slider (I assume). Do no longer exist. Try clicking them in the console to see if you can access them in the browser.
Last but not least. You tagged your question as "java". Javascript and java are not the same thing. Your problem involves javascript. Might want to change that tag next time so you can get anwsered faster.
I Hope this helped a bit :)
Good luck!
I am working with angular.js, and when I have some very, very wierd bugs with angular, I get stuck stepping through debugger hell.
Is there a way to have the Javascript console break on the first line of the next file accessed?
For instance, say I stepped through into angular.js.
Instead of stepping through angular and trying to get to the first line referenced of a next file, say "myFile.js," I would just like to tell the Javascript console to stop once it reaches a line of code from a different file than it is on right now, say, stop once it hits "myFile.js", or stop when it hits a line on anything other than the file "angular.js."
I have not mentioned any specific browser, for the fact that I assume that you may be able to do this with one browser and not the other.
I also understand that I should know my code well enough to know what the next line in the next file referenced should be, but the project I am working with is quite dynamic and it takes a lot of brain-power to figure out which line of which file I will actually hit next (ugh...)
I am having an incredibly difficult time figuring out how to include a jquery script in my html file. I keep getting an uncaught syntax error on the first line of the jquery file. The console points to the gibberish line "bookmark88D²~ýôÙ0’¹AÖ(±Users" which appears to be the beginning of my file path.
I know that this is not browser specific, as I'm having the same problem in both firefox and chrome. Additionally, I've checked the path, made sure that the link to the jquery script comes before the my javascript file, and tried multiple jquery versions. Does anyone know what's going on?
This isn't my code, I'm just troubleshooting it. Some code that has been working for over a year has now stopped working in Chrome (12.0.742.122), but works in the other "big" browsers (including fellow WebKit stablemate Safari (5.0.5)). By "not working anymore" I mean that although the script file does load, it doesn't execute. The kind of behaviour you'd expect if loading a script into innerHTML or writing it into a div, but neither of which things are being done. The commented-out lines below were all failed attempts at getting it working, the first of those being the original code that had worked up until recently.
<div id="abc"></div>
<script type="text/javascript">
var d=document.getElementById("abc");
var s=document.createElement('SCRIPT');
if(s){s.src=script_path;}
//if(d)d.appendChild(s); //original line that still works in all other browsers
//if(d)d.parentNode.appendChild(s);
//if(d)d.parentNode.insertBefore(s,d);
//if(d)d.parentNode.insertBefore(s,d.nextSibling);
document.body.appendChild(s); //this works, script executes
</script>
What is wanted from this code above, is that the script is a child of the div. Presumably they want to be able to remove that child and have all script be removed at the same time (I'm not sure of their motivation).
I've discovered what the problem was, largely thanks to Martin Bieder's back and forth and introducing me to jsfiddle.net with his working example.
The issue was actually the test page and what you'd think would be a fairly harmless error they made in creating it. The div and all of the code will be represented below simply as ######, as it's not even relevant to the problem. It's actually a HTML problem. Chrome 12 isn't happy if you don't match up your closing tags properly. I really can't believe that it has an effect on the execution on script files, but it does. I've tried many many times in the last 10 minutes with the HTML tags right and wrong and unbelievably this really is the problem.
<font><center><b>
##########
</b></font></center>
You see how the font and center closing tags are the wrong way around, and that's enough to confuse Chrome sufficiently that it won't execute any dynamic script being added within those tags. Bizarre. I can't recreate this on jsfiddle, probably due to the nature of the site runs the html/js that you put onto it (using onload for example).
No it works. Google Analytics uses is, too.
var ga=document.createElement('script');
ga.type='text/javascript';
ga.async=true;
ga.src='http://www.google-analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga,s);
Have you tried to set to async the script element?
var script = document.createElement('script');
script.async = 'async';
It is all about 3 things.. Organization, Optimization, and debugging.
1)properly scoping your tags makes things easier to read.
2)properly organizing your code makes it easier to parse which means parsers can be faster and more efficient.
3)alot of the debug tools we use rely on this organization in order to display things like collapsible tags and present a more visual scoping