我尝试使用jQuery DataTables,但我得到了错误
TypeError:c未定义
我不知道我的代码有什么问题,因为我可以看到JSON正确检索并且格式正确但我不知道它有什么问题我得到了上述错误.
我的JSON:
{"Data":[{"LOGIN":10184},{"LOGIN":10214},{"LOGIN":10180},{"LOGIN":10187},{"LOGIN":10179},{"LOGIN":10280},{"LOGIN":201},{"LOGIN":10238},{"LOGIN":10296},{"LOGIN":10312}]}
Run Code Online (Sandbox Code Playgroud)
和我的DataTables代码:
$(document).ready(function() {
$('#tablename').dataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"type": "POST",
"url": "https://test.com/api/db/select",
"data": function ( json ) { return JSON.stringify( { "Sql": 12 } );},
"contentType": "application/json; charset=utf-8",
"dataType": "json",
"processData": true,
beforeSend : function(xhr){
var access_token = sessionStorage.getItem('access_token');
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
}
},
"dataSrc": "Data",
"columns": [
{ "data": "LOGIN" }
]
} );
} );
Run Code Online (Sandbox Code Playgroud) 亲爱的朋友,我有一个奇怪的问题,我尝试连接到API,当我尝试在邮递员或失眠中做一切API请求时,一切都很好.当我在我的网站甚至在localhost上使用相同的代码时,潜在客户请求不起作用,并告诉我api-version未定义.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var settings = {
"async": true,
"crossDomain": true,
"url": "https://affiliate-api.tradingcrm.com:4477/token",
"method": "POST",
"data": "{ userName: \"alpt\", password: \"Alpt@12345\" }"
}
$.ajax(settings).done(function (response) {
var settings2 = {
"async": true,
"crossDomain": true,
"url": "https://affiliate-api.tradingcrm.com:4477/accounts/lead",
"method": "POST",
"headers": {
"Authorization": "Bearer " + response.Token,
"Api-Version": "3",
"Content-Type": "application/json"
},
"data": "{firstName:\"test\",lastName:\"test2\",email:\"test@test.test\"}"
}
$.ajax(settings2).done(function (response2) {
console.log(response2.accountId);
});
});
</script>Run Code Online (Sandbox Code Playgroud)