我有這個代碼,它總是以錯誤塊結束。我花了四個小時搜索,但沒有任何幫助。我想從一個URLjquery ajax從不工作
$.ajax({
url: 'http://google.com',
//data: {action : 'login', formData : $('#check-user').serialize()},
dataType: 'html',
type: 'get',
async: 'false',
//contentType: 'application/json; charset=utf-8',
//dataType: 'json',
beforeSend: function(xhr) {
//xhr.overrideMimeType("text/plain; charset=x-user-defined");
// This callback function will trigger before data is sent
//$.mobile.showPageLoadingMsg(true); // This will show ajax spinner
},
complete: function() {
// This callback function will trigger on data sent/received complete
// $.mobile.hidePageLoadingMsg(); // This will hide ajax spinner
},
success: function (result) {
alert(result);
if(result.status) {
//$.mobile.changePage("#second");
alert("Change Page");
} else {
alert('Logon unsuccessful!');
}
},
error: function (xhr, status, error) {
// This callback function will trigger on unsuccessful action
//var err = eval(xhr.responseText);
//alert(xhr.Message);
alert('Network error has occurred please try again! ');
}
});
你得到的錯誤是什麼? – ElGavilan
檢查您的控制檯。任何相同的來源策略錯誤?你不能做任何這樣的跨域請求 –
我總是得到這個警報('網絡錯誤發生了,請再試!');我想運行這個代碼作爲移動的Android應用程序,並使用移動jquery,並需要從網址調用URL。我相當新的移動jquery :( – user3347097