一直在试图找出我的代码有什么问题
<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。
发布于 2015-06-21 05:48:12
转换这个
$(#sendAuth)到这个
$("#sendAuth")在数据后面添加逗号
像这样
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);
}https://stackoverflow.com/questions/30961642
复制相似问题