2017-04-22 27 views
0

我運行到其內容在我的谷歌Chrome瀏覽器的控制檯遵循錯誤語法錯誤:與我的PHP腳本

Uncaught SyntaxError: Unexpected end of input

下面是我的代碼:

/*===== Login Alert ======*/ 

function loginAlert() { 
    swal({ 
     title: "Login Required", 
     type: 'error', 
     text: "Please <a href='/login'>login</a> first to submit your ticket.", 
     html: true, 
    }); 
} 

上午什麼我做錯了,我該如何解決它?

+1

你有','在那裏,不應該在那裏。此外,這看起來像JavaScript給我?所以,你的問題可能在其他地方,因爲你的錯誤確實在'php'內。 – Nytrix

+1

@Nytrix Re:逗號,請閱讀https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas – ceejayoz

回答

0

這就是你應該做的。

在下面的代碼片段看看:

$(document).ready(function() { 
 
    $("#loginBtn").on("click", function() { 
 
    swal({ 
 
     title: 'Login Required', 
 
     type: 'error', 
 
     text: 'Please <a href="login">login</a> first to submit your ticket.', 
 
     html: true, 
 
    }); 
 
    }); 
 
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" /> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script> 
 
<button id="loginBtn">Login Test</button>


Uncaught SyntaxError: Unexpected end of input錯誤你有表示你有沒有正確端接的功能或聲明。

查看this以瞭解更多細節和分辨率;你應該考慮通過你的代碼,因爲實際的錯誤必須在別的地方。