parse.com云代码有问题,但在javascript中工作得非常完美

parse.com云代码有问题,但在javascript中工作得非常完美,javascript,parse-platform,Javascript,Parse Platform,我花了8个小时在这段不想工作的代码上 在localhost和javascript上,它工作得很好,但在parse.com云代码中,我没有定义变量 Parse.Cloud.define("goGetPrices", function(request, response) { var price; function getPrices(stockPrice){ console.log(stockPrice); var PriceTick = Parse.Object.extend("Stock

我花了8个小时在这段不想工作的代码上

在localhost和javascript上,它工作得很好,但在parse.com云代码中,我没有定义变量

Parse.Cloud.define("goGetPrices", function(request, response) {

var price;

function getPrices(stockPrice){
console.log(stockPrice);

var PriceTick = Parse.Object.extend("StockPrices");
var queryInstal = new Parse.Query(Parse.Installation);

var queryLess = new Parse.Query(PriceTick);
var queryMore = new Parse.Query(PriceTick);

queryLess.equalTo("Position","Less");
queryLess.greaterThan("Price", stockPrice);

console.log(PriceTick) // RETURNS UNDEFINED
console.log(queryInstal) // RETURNS UNDEFINED
因为这些返回未定义,其余的代码无法工作…奇怪的是,这在没有云代码的本地主机上非常有效

queryLess.find({
success: function(results) {
//Less than

console.log("found less");

 if (results.length) {

for (var i = 0; i < results.length; i++) { 
var object = results[i]

var devicetoken = object.get('devicetoken');
var objID = object.get('objectId');

console.log("Got Less");
queryInstal.equalTo('deviceToken', devicetoken);
queryInstal.equalTo('deviceType', 'ios');

Parse.Push.send({
  where: queryInstal, // Set our Installation query
  data: {
    alert: "The price is now: "+stockPrice
  }
}, {
  success: function() {
    // Push was successful
          object.destroy({});


  },
  error: function(error) {
    // Handle error
  }
});
}
}},
 error: function(error) {
  alert("Error: " + error.code + " " + error.message);
 }
});




Parse.Cloud.httpRequest({
url: "example.php",
dataType: 'json',
type: 'GET',
success: function(data) {
 price = data.data.Response.price;
 response.success("yes")
 getPrices(price);

},
error: function(data) {
  response.error('Request failed with response code ' + data.status);

}
}); });
queryLess.find({
成功:功能(结果){
//少于
控制台日志(“发现较少”);
如果(结果长度){
对于(var i=0;i
您必须使用
Parse.Query(ClassName)
, 其中
ClassName
Parse.Object
子类的名称字符串或实例:


代码是否必须更改,因为它位于云上?
getPrices()
中的
console.log(stockPrice)
是否返回您期望的结果?不,它不返回任何内容。它应该发出一个推力,但什么也没发生。。。我可以确认它进入了循环。