0

I have this url with some xml data in it:

http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml

And I would like to load this xml data into my javascript script so I can parse it. I am using parse.com Javascript SDK, in there cloud code.

jQuery seems either not to work with Parse cloud code, or I cannot get it to work. So is there a way to load the xml data (xml tree), with javascript without using jQuery?


THIS IS NOT WORKING, I DONT THINK IT CAN WORK


Here is the code I have tried:

Parse.Cloud.define("next", function(request, response) {
  response.success("Hello world!");

  $.ajax({
    url: 'http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml', // name of file you want to parse
    dataType: "xml", // type of file you are trying to read
    success: parse, // name of the function to call upon success
    error: function(){alert("Error: Something went wrong");}
  });
});

But when I run this I get an error:

$ is not defined

at main.js:

3 Answers3

0

I do not know how parse.com works but $ refers to jQuery and it seems that it is not included, at least at the time that you run your script.

Maybe try this jQuery wrapper for parse.com https://github.com/srhyne/jQuery-Parse

0Ds0
  • 598
  • 5
  • 19
  • This doesn't work as I am using the javascript SDK not REST API. Do you know a way of loading the xml data of a URL in Javascript? I am able to parse it I just need to get the data from a URL, preferably without using jQuery –  Aug 20 '14 at 23:18
  • You should use the XMLHttpRequest, you can try and look it up here http://www.w3schools.com/ajax/ajax_xmlfile.asp or here http://stackoverflow.com/questions/11527238/load-xml-file-in-a-directory-using-javascript and refer to https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest – 0Ds0 Aug 21 '14 at 08:54
0

use a j query wrapper

$.ajax({
url: 'http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml', // name of file you want to parse
dataType: "xml", // type of file you are trying to read
success: parse, // name of the function to call upon success
error: function(){alert("Error: Something went wrong");}

});

iqueqiorio
  • 1,149
  • 2
  • 35
  • 78
0

This should help you

url: 'http://64.182.231.116/~spencerf/union_college/Upperclass_Sample_Menu.xml', // name of file you want to parse
dataType: "xml", // type of file you are trying to read
success: parse, // name of the function to call upon success
error: function(){alert("Error: Something went wrong");}