(function($, doc) {
$.init();
$.plusReady(function() {
// plus.nativeUI.toast(txt);
//成功响应的回调函数
var respnoseEl = document.getElementById("response");
var success = function(response) {
var dataType = 'json';
if (dataType === 'json') {
response = JSON.stringify(response);
} else if (dataType === 'xml') {
response = new XMLSerializer().serializeToString(response).replace(/</g, "<").replace(/>/g, ">");
}
respnoseEl.innerHTML = response;
};
//设置全局beforeSend
$.ajaxSettings.beforeSend = function(xhr, setting) {
//beforeSend演示,也可在$.ajax({beforeSend:function(){}})中设置单个Ajax的beforeSend
console.log('beforeSend:::' + JSON.stringify(setting));
};
//设置全局complete
$.ajaxSettings.complete = function(xhr, status) {
console.log('complete:::' + status);
console.log('complete:::' + xhr);
}
var ajax = function() {
//利用RunJS的Echo Ajax功能测试
//var url = 'http://runjs.cn/action/echo/json';
//var url='http://221.234.36.202:36059//WebAPI/HomePage.ashx';
var url = 'https://192.168.100.58:8443/qilianbao/control/testAppAjax';
//请求方式,默认为Get;
var type = 'get';
//预期服务器范围的数据类型
var dataType = 'json';
//发送数据
var data = {
/* name: "mui",
version: "pre-release",
author: "chb",
description: "最接近原生APP体验的高性能前端框架"*/
account: "11",
password: "111",
phone: "111",
name: "aaa"
};
//url = url + (dataType === 'html' ? 'text' : dataType);
respnoseEl.innerHTML = '正在请求中...';
$.ajax(url, {
dataType: 'json',
type: 'post',
timeout: 20000,
success: function(data) {
//var response = JSON.stringify(data);
//alert(data.data.jsondata.length);
alert(JSON.stringify(data.data.jsondata[0].token));
//alert(111);
},
error: function(xhr, type, errorThrown) {
$.alert(errorThrown, '提示');
}
});
//$.getJSON(url, data, success);
/* if (type === 'get') {
if (dataType === 'json') {
$.getJSON(url, data, success);
} else {
$.get(url, data, success, dataType);
}
} else if (type === 'post') {
$.post(url, data, success, dataType);
}*/
};
document.getElementById("confirm").addEventListener('tap', function() {
ajax();
});
});
})(mui, document);
错误提示是
[LOG] : beforeSend:::{"dataType":"json","type":"post","timeout":20000,"url":"https://192.168.100.58:8443/qilianbao/control/testAppAjax","context":null,"accepts":{"script":"text/javascript, application/javascript, application/x-javascript","json":"application/json","xml":"application/xml, text/xml","html":"text/html","text":"text/plain"},"processData":true,"cache":true}
[LOG] : complete:::abort
[LOG] : complete:::[object XMLHttpRequest]
张静
请问你的https有什么问题,我也遇到了这样的问题
2015-11-10 14:32