我无法使用AJAX向服务URL参数发送值。值为6946602c34d442a6
。我将此值发送到以下网址:
$('#btn').click(function() {
var userName = $('#Username').val();
var password = $('#password').val();
var lg_dev = device.uuid;
var lginfo = lg_dev.toString();
var urlInfo = "http://xxx.xxx.xxx.xxx:xx/Service1.svc/log";
$.ajax({
type: 'GET',
url: urlInfo,
data: "uid=" + userName + "&pwd=" + password + "&DeviceId=" + lginfo + "",
success: function(resp) {
var data1 = resp;
console.log(data1);
},
error: function(e) {
// SpinnerPlugin.activityStop();
window.plugins.toast.showLongBottom("Invalid Data");
// SpinnerPlugin.activityStop();
}
});
});
直到数据部分数据正在增加,但稍后它直接指向错误部分并在调试时。它显示此错误:
并且在使用邮递员时我能够获得当天及以下是我用于登录的数据
{
"Id": "2",
"DeviceID": "6956303c32d442a1",
"Extension": "@nazu.nz",
"Name": "nazu",
"Password": "nazu",
"UserName": "mxa",
"sno": 3,
"status": true
}
在调试时它也会转到jquery文件
while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
// a subset or equal to those in the bound event (both can have no namespace).
if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) {
if ( ( event.result = ret ) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
之后它将会
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
},
然后转到
callback = function( type ) {
return function() {
if ( callback ) {
callback = errorCallback = xhr.onload =
xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
if ( type === "abort" ) {
xhr.abort();
} else if ( type === "error" ) {
// Support: IE9
// On a manual native abort, IE9 throws
// errors on any property access that is not readyState
if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
}
} else {
complete(
xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText,
// Support: IE9 only
// IE9 has no XHR2 but throws on binary (trac-11426)
// For XHR2 non-text, let the caller handle it (gh-2498)
( xhr.responseType || "text" ) !== "text" ||
typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders()
);
}
}
};
};
答案 0 :(得分:-1)
这应该澄清一点:
$('#btn').click(function() {
var userName = $('#Username').val();
var password = $('#password').val();
var lg_dev = device.uuid;
var lginfo = lg_dev.toString();
var urlInfo = "http://xxx.xxx.xxx.xxx:xx/Service1.svc/log";
$.ajax({
type: 'GET',
url: urlInfo,
data: {
uid: userName,
pwd: password,
DeviceId: lginfo
},
success: function(data, status, xhr) {
console.log(arguments);
if (data) {
var data1 = data;
} else {
console.log('Server sent an empty response.');
}
},
error: function(xhr, status, error) {
console.log('Ajax failed', arguments);
// SpinnerPlugin.activityStop();
window.plugins.toast.showLongBottom("Invalid Data");
// SpinnerPlugin.activityStop();
}
});
});