XML : Node js script with ajax xml request not working

I've got a short javascript script that I'm running with node (e.g. node runScript.js). Within it, I'm using tiptoe, and I've tried various ways of retrieving an xml file without success.

  tiptoe(          function getESData() {                  var json;                  // get the json data.                  for (var i = 0; i < json.hits.hits.length; i++) {                                              for (var multiId = 0; multiId < json.hits.hits[i]._source.multiverseids.length; multiId++) {                                  var priceUrl = "http://partner.tcgplayer.com/x3/phl.asmx/p?pk=TCGTEST&s="+setName+"&p="+json.hits.hits[i]._source.name                                          console.log("fetching " +priceUrl );                                          // attempt 1:                                          var x = new XMLHttpRequest();                                          console.log("working"); // THIS CONSOLE LOG NEVER SHOWS UP.                                          x.open("GET", priceUrl, true);                                          console.log("working");                                          x.onreadystatechange = function() {                                                  if (x.readyState == 4 && x.status == 200)                                                  {                                                          console.log(x.responseXML);                                                  }                                          };                                          x.send();                                          // attempt 2:                                          $.ajax({                                                  url: priceUrl,                                                  success: function( data ) {                                                    console.log(data);                                                  }                                          });                                          // attempt 3:                                                            $.get(priceUrl, function(data, status){                                          console.log("Data: " + data + "\nStatus: " + status);                                      });                                  }                          }              });          }  );  

All of these methods fail silently (obviously I comment out all but one when testing, I don't use all three at once), after printing the first console.log where I log the url to make sure it works. (The urls with the variables resolve to something like this: http://partner.tcgplayer.com/x3/phl.asmx/p?pk=TCGTEST&s=Ice Age&p=Arnjlot's Ascent which absolutely returns xml when I test it in a browser, so I know that's working). Is it something with tiptoe?

No comments:

Post a Comment