[英]Is there a simple way to convert a unique string of characters into a unique number in JavaScript?
[英]how to convert a unique number in to string using javascript
我无法使用AJAX向服务URL参数发送值。 值是6946602c34d442a6
。 我将此值发送到以下URL:
$('#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()
);
}
}
};
};
这应该使事情澄清一些:
$('#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();
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.