0
一直在努力尋找有什麼錯我的代碼在這裏:意外標記非法的。點擊()
<p class="text text-2">Name:</p>
<input class="_input-1" type="text" id="usernameCs">
<p class="text text-4">Email:</p>
<input class="_input-2" type="text">
<p class="text text-6">Phone:</p>
<input class="_input-5" type="text">
<button id ="sendAuth" onclick="javascript:void(0);">SEND</button>
<script>
$(document).ready(function(){
$(#sendAuth).click(function(){
var csUsername = $("#usernameCs").val();
$.ajax({
url: 'http://warwick.a2retail.com',
type: 'POST',
contentType: 'application/json',
data: {
transactionType: 'basic_user_information_login',
requesterName: 'Project Eden',
serviceProviderId: 'rlp-99b3c3df-9e25-4503-bbb9-a92126d6afb6',
userId: 'csUsername',
payload: {}
}
success: function(data) {
console.log(data);
}
});
});
});
本質上講,我試圖讓一個AJAX POST請求,但不能左右我的頭我得到的錯誤。我在$(#sendAuth).click(function(){
行發生錯誤。我已經正確引用了jQuery。
你錯過了data'後'一個逗號後面添加逗號。 –
它應該是'$(「#sendAuth」)',你需要在引號中傳遞選擇器。投票結束爲排錯 – Satpal
在AJAX的「成功」之前是否缺少','? – Varun