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 Answers 3

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");}

});

Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

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
You should use the XMLHttpRequest, you can try and look it up here w3schools.com/ajax/ajax_xmlfile.asp or here stackoverflow.com/questions/11527238/… and refer to developer.mozilla.org/en/docs/Web/API/XMLHttpRequest
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");}

Comments