2013-04-29 99 views
0

一旦這個問題指向我,我會感覺自己像個白癡,但是我有一個語法錯誤,我找不出問題來自哪裏。這裏是我的代碼(在最後一行出現錯誤,但我懷疑它是導致該行):我找不到這個語法錯誤

// handle GCM notifications for Android 
function onNotificationGCM(e) { 
switch(e.event) 
{ 
    case 'registered': 
    if (e.regid.length > 0) 
    { 
     // Your GCM push server needs to know the regID before it can push to this device 
     // here is where you might want to send it the regID for later use. 
     PushWoosh.appCode = "33F93-5013B"; 
     PushWoosh.register(e.regid, function(data) { 
        alert("PushWoosh register success: " + JSON.stringify(data)); 
       }, function(errorregistration) { 
        alert("Couldn't register with PushWoosh" + errorregistration); 
       }); 

    } 
break; 

感謝球員,我在這裏感覺就像個白癡,是令人沮喪的一天了。

+0

提示:http://jslint.com或http://jshint.com – 2013-04-29 19:48:37

+0

你能給出實際的錯誤嗎? – 2013-04-29 19:49:13

+0

根據javascriptlint.com它是「SytaxError:語法錯誤」。雖然我發現如果刪除我的代碼的特定部分,錯誤消失。讓我編輯它並顯示我認爲的故障碼。感謝球員 – nikobradshaw 2013-04-29 19:51:53

回答

2

您的onNotificationGCM()函數未關閉,其中包含的開關塊也不關閉。 JavaScript解析器期望看到兩個額外的大括號(}),但輸入文件在被看到之前終止。

我的猜測是你需要在你的break;聲明之後添加這兩個大括號,在PushNotification.prototype.register的分配之前。

+0

Bah我會upvote你,但我沒有代表。我會標記它。在編輯中,我將把修復它的代碼。謝謝你們,你們都很棒! – nikobradshaw 2013-04-29 20:00:03