Uncaught SyntaxError: Unexpected string in my javascript file
Uncaught SyntaxError: Unexpected string in my javascript file
这是我的 likedc.js,我尝试上传,但终端报告我上传失败,因为 错误:未捕获的语法错误:likedc.js:40 中的意外字符串main.js:3:1
我试图发表评论,但终端仍然说同样的话。我不确定我可以修改哪些替代方案
Parse.Cloud.define("StatusUpdate", function(request,response){
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message)
badge: "Increment", **//<---- Line 40**
sound: "";
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
}
},
error: function(error) { // <--- Line 54**
alert("Error: " + error.code + " " + error.message);
}
});
})
});
var alertMessage = function createMessage(request)
{
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
}
data: {
alert: createMessage(message), //<-- add comma here
badge: "Increment", **//<---- Line 40**
sound: "" //<-- remove semicolon here
}
对于第二部分,从上下文我认为你的错误块不合适,尝试重新排列
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment", //<---- Line 40**
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
});
}
},
error: function(error) { // <--- Line 54**
alert("Error: " + error.code + " " + error.message);
}
});
});
这是我的 likedc.js,我尝试上传,但终端报告我上传失败,因为 错误:未捕获的语法错误:likedc.js:40 中的意外字符串main.js:3:1
我试图发表评论,但终端仍然说同样的话。我不确定我可以修改哪些替代方案
Parse.Cloud.define("StatusUpdate", function(request,response){
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message)
badge: "Increment", **//<---- Line 40**
sound: "";
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
}
},
error: function(error) { // <--- Line 54**
alert("Error: " + error.code + " " + error.message);
}
});
})
});
var alertMessage = function createMessage(request)
{
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
}
data: {
alert: createMessage(message), //<-- add comma here
badge: "Increment", **//<---- Line 40**
sound: "" //<-- remove semicolon here
}
对于第二部分,从上下文我认为你的错误块不合适,尝试重新排列
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment", //<---- Line 40**
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
});
}
},
error: function(error) { // <--- Line 54**
alert("Error: " + error.code + " " + error.message);
}
});
});