tags:

views:

23

answers:

2

I have two functions

function ShowCrossWord(var randN)
{
     randomnumber = randN;

     $(document).ready(function() {
       $.get("crosswords.xml",{},function(xml){
         $('crossword',xml).each(function(i) {  });
       });
     });
}

and

  function ShowLegend(var randN)
  {
    randomnumber = randN;
    $(document).ready(function() {
      $.get("legends.xml",{},function(xml){         
            $('legend',xml).each(function(i) {});
      });

    });
  }

I am using these in a same javascript file:

   var randomNumber=Math.floor(Math.random()*233);   
   ShowCrossWord(randomNumber);
   ShowLegend(randomNumber);

None of them seems to work. What would be the solution.

A: 

What were you expecting to happen, and what actually happened?

So things I can see:

  • You never do anything with the XML data. I presume it is not even being returned?
  • You may need to specify a dataType attribute of "xml" so jQuery knows what type of data the server is returning.

I recommend you double-check these points above, and then use FireBug to further narrow-down the problem.

Justin Ethier
A: 

I would guess your mimetype of the XML sent from the server is wrong. It's very picky to get that right, or the XML will not be parsed on the client.

You could try to register callback functions for success and error and log the error message and the XMLHTTPRequest object.

geon