views:

66

answers:

2

Hello. I'm learning javascript and jquery and have written a very basic script inside my file. I'm experiencing two problems...

  1. The browser never finishes loading the document, it just sits there with the loading icon animating in the tab. Any ideas?
  2. I can't seem to debug this using firebug. When I set a breakpoint anywhere in the document load function, it never hits. Any ideas?

Here's my code...

<html>
<head>
 <title>Untitled Document</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link media="screen" type="text/css" href="default.css" rel="stylesheet">  
 <script src="jquery-1.3.2.min.js" type="text/javascript"></script>

 <script type="text/javascript">
 $(function()
 {
  var strMarkup = "";
  var strXMLFile = "";

  //Parse XML and generate accordion elements
  var arrayAccordianElements = ParseXML(strXMLFile);

 }); 

 function ParseXML(strPath)
 {
  var arrayEvents = new Array();
  arrayEvents[0] = "test1";
  arrayEvents[1] = "test2";
  arrayEvents[2] = "test3";

  //Return the accordian elements
  return arrayEvents;
 }  
 </script>
</head>
<body>
 hello
</body>
</html>

As you experts can see, my webpage should simply display "hello" after processing some javascript that creates an array inside of a function. Do you see any problems? I apologize if they're obvious problems, I'm a noob :)

Thanks in advance for all your help!

+1  A: 

Code-wise I don't see anything that would cause an infinite loop at all. However, knowing firefox etc, there may be a variety of things out of your control. Start with restarting the browser. Profile the script with Firebug (Console > Profile > Reload the page > Press profile again), and see what part takes most time.

One thing, probably unrelated, close your link tag. is sufficient.

Dmitri Farkov
There's no need to close the link tag.
Tim Down
Why not? Each tag has an opening and a closure. Sure the old standards were rather forgiving so it is not **mandatory** to close it, but semantically you should.
Dmitri Farkov
er... why? I'm pretty sure that HTML 4-5 browsers are smart enough to auto-close tags where the end tag is forbidden (and it IS forbidden on meta and link tags).
R. Bemrose
In that case let's add more to the debate and say that it depends on your doctype. If it is XHTML then close your tags, otherwise don't since closing <link> is actually against HTML standard. Btw, relying on the browser is risky, you wouldn't leave <td> or <tr> unclosed would you?
Dmitri Farkov
@Dmitri: to an HTML parser, the /> construct is actually an ignorable error (an attribute with the invalid name "/" to be precise). Empty elements should only be explicitly closed that way in XML documents such as XHTML.
NickFitz
+1  A: 

Runs fine for me in Safari 4.0.3. Make sure your path to jQuery is correct? If it is incorrect and there's something misconfigured and jQuery fails to load, that will hang indefinitely.

eyelidlessness
thanks for checking that for me!
BeachRunnerJoe