Title: Parse.com error with document.createElement('script')
Tags: javascript;json;parse-platform;cloud;jsonp
Question: I'm trying to use this code with Parse.Cloud.beforeSave...
var script = document.createElement('script');
and I get this: Result: ReferenceError: document is not defined
How can I use document with Parse.Cloud?
My code:
function getJSONP(url, success) {
var script = document.createElement('script');
script.src = url.replace('callback=', 'callback=do');
document.head.appendChild(script);
do = function (data) {
success(data);
}
Comment: Parse Cloud code does not run in the browser. It runs on the server where the DOM does not exist. Why are you trying to use the DOM?

Comment: Not sure if Parse allows it, but you could just make a normal HTTP request and `eval` the response. JSONP is only used to circumvent the same-origin policy in the browser. There is no need for script tags on the server side, just make the HTTP request.

Comment: I wonder if you can somehow use [jsdom](https://github.com/tmpvar/jsdom) on Parse.com? Alternatively, does [this question and answer help](https://stackoverflow.com/questions/27908054/parse-xml-html-string-with-parse-com)?

Comment: I'm trying to download a JSONP...                                                              function getJSONP(url, success) {
var script = document.createElement('script');
script.src = url.replace('callback=', 'callback=do');
document.head.appendChild(script);
do = function (data) {
console.log(data);
success(data);
}

Comment: Thanks! @FelixKling the solution is Parse.Cloud.httpRequest.

Here is the accepted answer: The solution:
Parse.Cloud.httpRequest({
url: myURL,
success: function(httpResponse) {
console.log(httpResponse.data);
response.success();
}, error: function(httpResponse) {
response.error('Request failed...');
}


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:06/23/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><json><parse-platform><cloud><jsonp>', 'Title': "Parse.com error with document.createElement('script')", 'ViewCount': 137, 'id': 30994514, 'user_AboutMe': None, 'user_AccountId': 5674690.0, 'user_DisplayName': 'Geek20', 'user_Reputation': 633.0, 'user_Views': 67.0, 'user_id': 4488301.0}}