0

编写 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: $ is not defined\n at main.js:5:20

4

1 回答 1

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

于 2013-08-13T09:37:32.080 回答