Error during sAjaxSource call
Error during sAjaxSource call
Hi, I'm a young italian developer at first time on this forum.
WellI 'm making a local website and when I run this script
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate",
"aoColumns": [
{ "mData": "owner" },
{ "mData": "size" },
{ "mData": "status" },
{ "mData": "title" },
{ "mData": "grade" }
]
} );
} );
[/code]
I obtain this error :
[quote] "XMLHttpRequest cannot load http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate?_=1372782614035. Origin null is not allowed by Access-Control-Allow-Origin." [/quote]
Thank to everyone help me!!
WellI 'm making a local website and when I run this script
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate",
"aoColumns": [
{ "mData": "owner" },
{ "mData": "size" },
{ "mData": "status" },
{ "mData": "title" },
{ "mData": "grade" }
]
} );
} );
[/code]
I obtain this error :
[quote] "XMLHttpRequest cannot load http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate?_=1372782614035. Origin null is not allowed by Access-Control-Allow-Origin." [/quote]
Thank to everyone help me!!
This discussion has been closed.
Replies
Second, if I do this (a simple ajax call in the same script):
[code]
$.ajax({
type:"GET",
url:"http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate",
dataType:"jsonp",
timeout:"20000",
crossDomain : true,
data: {format :"jsonp"},
success:function(json) {
console.log ("json");
}}});[/code]
it's work fine!! Why?
question : How I can set the same in DataTable??
DataTables 1.10 will include an `ajax` option which makes this somewhat easier.
Allan
I've done what you said me ..
[code]
$('#tab').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://46.37.13.177:7710/WebClinicalDataAPI/GetDocumentsToValidate?format=jsonp",
"fnServerData": function( sUrl, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}
} );
[/code]
but now the error is :
[quote]Uncaught TypeError: Cannot read property 'length' of undefined at jquery.dataTables.js:2038[/quote]
what's wrong?
[quote]for ( var i=0, iLen=aData.length ; i
Allan
[quote]
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
[/quote]
I must to put the value of the field or the name???
The parameters for the object you highlighted are for the jQuery Ajax call and don't really have that much to do with DataTables. See: http://api.jquery.com/jQuery.ajax/
Allan