0
我得到這個代碼錯誤,但它應該工作。我想發送數據到loginck.php
並獲得服務器響應。任何錯誤?
<link rel="stylesheet" href="css/jquery.mobile-1.3.0-beta.1.css" />
<link rel="stylesheet" href="css/jqm-docs.css"/>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jqm-docs.js"></script>
<script src="js/jquery.mobile-1.3.0-beta.1.js"></script>
HTML:
<div data-role="popup" id="popupLogin" data-theme="a" class="ui-corner-all">
<form action="#" method="post" autocomplete="off">
<div style="padding:10px 20px;">
<h3>Please sign in</h3>
<label for="un" class="ui-hidden-accessible">Username:</label>
<input type="text" name="username" id="un" value="" placeholder="username" data-theme="a" />
<label for="pw" class="ui-hidden-accessible">Password:</label>
<input type="password" name="password" id="pw" value="" placeholder="password" data-theme="a" />
<button type="submit" name="submit" id="submit" value="submit-value" data-theme="b">Sign in</button>
</div>
</form>
</div>
$阿賈克斯:
$(window).load(function(e){
$('#submit').bind('click', function(e) {
e.preventDefault();
$.ajax({
type : "POST",
url : "loginck.php",
crossDomain: true,
beforeSend : function() {$.mobile.loading('show')},
complete : function() {$.mobile.loading('hide')},
data : {username : 'subin', password : 'passwordx'},
dataType : 'json',
success : function(response) {
//console.error(JSON.stringify(response));
alert(response);
},
error : function() {
//console.error("error");
alert('Not working!');
}
});
});
});
你的錯誤是什麼?以及控制檯日誌中的內容? – KeepCalmAndCarryOn
即時通訊提醒「不工作!」 –
你能直接從瀏覽器調用'loginck.php?username = subin&password = passwordx'嗎?你確定沒有什麼在日誌中http://stackoverflow.com/questions/4743730/what-is-console-log-and-how-do-i-use-it – KeepCalmAndCarryOn