编写parse.cloud代码以读取跨域xml。 我已经尝试过使用jquery-ajax,但我遇到语法问题我的代码是
Parse.Cloud.define("read", function(request, response) {
var query = 'http://data.gov.in/sites/default/files/Date-Wise-Prices-all-Commodity.xml&callback=?';
$.ajax({
url: query,
type: 'GET',
dataType: 'json',
success: function(s) {
response.success("Success");
},
error: function(e)
{
response.success("Error "+e)
}
});
});
我收到以下错误:
“code”:141,“error”:“ReferenceError:$未定义\ n在main.js:5:20
答案 0 :(得分:1)
使用Parse.Cloud.httpRequest
Parse.Cloud.httpRequest({
url: 'http://data.gov.in/sites/default/files/Date-Wise-Prices-all-Commodity.xml',
success: function(httpResponse) {
// httpResponse.data will hold the returned object
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
https://www.parse.com/docs/cloud_code_guide#networking https://parse.com/docs/js/symbols/Parse.Cloud.HTTPResponse.html