can not get external data

can not get external data

redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
edited March 2010 in General
Hi,

Please see below. If I put json in the same page, it works fine, if I call it from the external page, no error, no data on the page. I have tried {} and "{}". Please help.....Also, this is a great piece of software...thanks...I am gong to donate some $$ ...thanks again LOL

[code]


$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bFilter": true,
//"sAjaxSource": {"sEcho": 0, "iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData": [ ["Trident","Internet Explorer 4.0","Win 95+","4","X"],["Trident","Internet Explorer 5.0","Win 95+","5","C"],["Trident","Internet Explorer 5.5","Win 95+","5.5","A"],["Trident","Internet Explorer 6","Win 98+","6","A"],["Trident","Internet Explorer 7","Win XP SP2+","7","A"],["Trident","AOL browser (AOL desktop)","Win XP","6","A"],["Gecko","Firefox 1.0","Win 98+ / OSX.2+","1.7","A"],["Gecko","Firefox 1.5","Win 98+ / OSX.2+","1.8","A"],["Gecko","Firefox 2.0","Win 98+ / OSX.2+","1.8","A"],["Gecko","Firefox 3.0","Win 2k+ / OSX.3+","1.9","A"],["Gecko","Camino 1.0","OSX.2+","1.8","A"],["Gecko","Camino 1.5","OSX.3+","1.8","A"],["Gecko","Netscape 7.2","Win 95+ / Mac OS 8.6-9.2","1.7","A"],["Gecko","Netscape Browser 8","Win 98SE+","1.7","A"],["Gecko","Netscape Navigator 9","Win 98+ / OSX.2+","1.8","A"],["Gecko","Mozilla 1.0","Win 95+ / OSX.1+","1","A"],["Gecko","Mozilla 1.1","Win 95+ / OSX.1+","1.1","A"],["Gecko","Mozilla 1.2","Win 95+ / OSX.1+","1.2","A"],["Gecko","Mozilla 1.3","Win 95+ / OSX.1+","1.3","A"],["Gecko","Mozilla 1.4","Win 95+ / OSX.1+","1.4","A"],["Gecko","Mozilla 1.5","Win 95+ / OSX.1+","1.5","A"],["Gecko","Mozilla 1.6","Win 95+ / OSX.1+","1.6","A"],["Gecko","Mozilla 1.7","Win 98+ / OSX.1+","1.7","A"],["Gecko","Mozilla 1.8","Win 98+ / OSX.1+","1.8","A"],["Gecko","Seamonkey 1.1","Win 98+ / OSX.2+","1.8","A"],["Gecko","Epiphany 2.20","Gnome","1.8","A"],["Webkit","Safari 1.2","OSX.3","125.5","A"],["Webkit","Safari 1.3","OSX.3","312.8","A"],["Webkit","Safari 2.0","OSX.4+","419.3","A"],["Webkit","Safari 3.0","OSX.4+","522.1","A"],["Webkit","OmniWeb 5.5","OSX.4+","420","A"],["Webkit","iPod Touch / iPhone","iPod","420.1","A"],["Webkit","S60","S60","413","A"],["Presto","Opera 7.0","Win 95+ / OSX.1+","-","A"],["Presto","Opera 7.5","Win 95+ / OSX.2+","-","A"],["Presto","Opera 8.0","Win 95+ / OSX.2+","-","A"],["Presto","Opera 8.5","Win 95+ / OSX.2+","-","A"],["Presto","Opera 9.0","Win 95+ / OSX.3+","-","A"],["Presto","Opera 9.2","Win 88+ / OSX.3+","-","A"],["Presto","Opera 9.5","Win 88+ / OSX.3+","-","A"],["Presto","Opera for Wii","Wii","-","A"],["Presto","Nokia N800","N800","-","A"],["Presto","Nintendo DS browser","Nintendo DS","8.5","C/A1"],["KHTML","Konqureror 3.1","KDE 3.1","3.1","C"],["KHTML","Konqureror 3.3","KDE 3.3","3.3","A"],["KHTML","Konqureror 3.5","KDE 3.5","3.5","A"],["Tasman","Internet Explorer 4.5","Mac OS 8-9","-","X"],["Tasman","Internet Explorer 5.1","Mac OS 7.6-9","1","C"],["Tasman","Internet Explorer 5.2","Mac OS 8-X","1","C"],["Misc","NetFront 3.1","Embedded devices","-","C"],["Misc","NetFront 3.4","Embedded devices","-","A"],["Misc","Dillo 0.8","Embedded devices","-","X"],["Misc","Links","Text only","-","X"],["Misc","Lynx","Text only","-","X"],["Misc","IE Mobile","Windows Mobile 6","-","C"],["Misc","PSP browser","PSP","-","C"],["Other browsers","All others","-","-","U"]] }
"sAjaxSource": "testData.asp"
} );
} );

[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi redhookbaker,

    Thanks for the donation :-). The sAjaxSource property tells DataTables what page it should load from the web-server to get the JSON data. There are a number of different ways that you can deal with JSON data with DataTables:

    1. Javascript array - when you have the data already on the client-side - http://datatables.net/examples/data_sources/js_array.html

    2. Ajax file - load an JSON file (all data records in a single go) and have all the processing (sorting, filtering etc) done on the client-side: http://datatables.net/examples/data_sources/ajax.html

    3. Server-side processing - have all the processing done by the server (typically an SQL database or the like): http://datatables.net/examples/data_sources/server_side.html . This is great when you've got a large amount of data to display.

    Which is it that you are trying to use? If server-side processing, then your ASP script will need to reply to the request sent by DataTables as needed: http://www.datatables.net/usage/server-side . There are some sample scripts in this thread http://datatables.net/forums/comments.php?DiscussionID=937 - although I'm afraid I know nothing about ASP, so might not be a huge amount of help there.

    Regards,
    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    Hi, Allan,

    Thanks for the quick reply. The external page I use is called testData.asp, when I run this page directly, here is what I have, I tried with/with out "", it does not show data. It also passes validation as a valid json..thanks

    [code]
    "{"aaData": [ ["1","demo1 ","demo2 ","","demo3 "], ["2","DEMO ","DEMO ","","DEMO "], ["3","demo Group ","demo group ","","winter "], ["5","ml llc ","ml llc1 ","","MLDirect "] ]}"
    [/code]
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    oh, btw, I am getting data from SQL thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Right - so it looks like you are using option 2 - loading Ajax from a file and using client-side processing (not server-side).

    Try this then:

    [code]

    $(document).ready(function() {
    $('#example').dataTable( {
    "bProcessing": true,
    "sAjaxSource": "testData.asp"
    } );
    } );

    [/code]
    Note that filtering is on by default, so I've dropped that out.

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    it is odd, if I plug http://www.datatables.net/examples/examples_support/server_processing.php in, it works, but using my asp page, it doesnt.

    The end result by running php and asp is the same, really strange...
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you confirm if you want to use client-side, or server-side processing please? The JSON structure needed for each is different. Server-side processing needs a few more parameters.

    The link you gave is for server-side processing (option 3), but the JSON structure you gave is for client-side processing (option 2).

    Can you provide a link to the page please?

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    this is the test data I am using, this is from a table from SQL, please have a look...thanks


    http://209.59.1.252/testdata.asp
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Right - so what happens if you do:

    [code]

    $(document).ready(function() {
    $('#example').dataTable( {
    "bProcessing": true,
    "sAjaxSource": "testData.asp"
    } );
    } );

    [/code]
    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    I am getting "Processing..." but no data,
    but if I use http://209.59.1.252/testdata.asp, bServerSide set to True or False, i am getting
    DataTable Warning: Added data does not match number of known columns.....

    I am sorry to keep bugging you..thanks
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    I found out something is strange, if I use http://209.59.1.252/testdata.asp, it works fine.

    Exact same data, if I call the page name (testdata.asp), it does not work; if I use the local rurl (http://my-pc...../testdata.asp), it doesnt work......how weird is that? thx
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I think you might be running into a XSS issue: http://en.wikipedia.org/wiki/Cross-site_scripting . You can load Ajax data from anything but the domain name which the original document is loaded in. So if you are loading from file:/// you are going to have a whole lot of problems. Or if loading from a site which isn't the same as where the document was loaded from...

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    I just uploaded to another server and getting this error:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Wed, 10 Mar 2010 15:20:30 UTC


    Message: Access is denied.

    Line: 127
    Char: 287
    Code: 0
    URI: https://www.mysite.com/js/jquery.js



    any thoughts? thanks
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    looks like it is working now....I will post back....

    in the meantime, is there any documentation regarding the settings, such as the parameter list

    bProcessing
    bServerSide
    bFilter
    ...


    thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes indeed: http://datatables.net/usage/features

    Also this page ( http://datatables.net/usage/ ) defines the different data sources. It really is sounding like an XSS issue...

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    How can I pass the parameter to the external page? using query string?

    thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes - just a query string on the URL to load would do. "testdata.asp?hello=world" for example.

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    is there a way to "flush" the page becasue the same data source sometimes it works, sometimes it doesnt..thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Not really... The flush would be done on the server-side, not the client-side (unless you mean flush as in 'clear' - in which can fnClearTable would do). Perhaps looking at what the XHR is doing in Firebug would help.

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    hi,

    I am going to try Java array, can you point me to the document/seetings for java array? thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm not sure what you mean. Where would you just the Java array and how? To output the JSON data?

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    I am using the code based on this example
    http://datatables.net/examples/data_sources/js_array.html

    I get the data from SQL and parse it into java array and it works great....thanks

    I want to see if there are options like the server-side that can set bFilter=false, something like that...thanks
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    is there a way to disable Seach box in javaarray? thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I think you might be confusing Java with JavaScript in your above posts - hence the confusion :-). DataTables is entirely Javascript based and has nothing at all to do with Java.

    > I want to see if there are options like the server-side that can set bFilter=false, something like that...

    Yes - the same options apply as client-side processing. Using a JS array (in the example link you posted) is client-side processing. So bFilter:false will do it. Did you try that? That will also remove the filter box. All of the configuration parameters are listed in the 'Usage' section of this site.

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    Thank you. I guess I have two more question (so far) sorry

    1. How can I change the sorting column color ?
    2. Is there a way to hightlight rows when mouse mover? thx
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    1. Yes - using CSS. 'sorting_1' is the class. Worth opening Firebug to look at what the mark up is.
    2. Again yes - using CSS :hover - http://www.google.com/search?q=css+%3Ahover

    Allan
  • redhookbakerredhookbaker Posts: 31Questions: 0Answers: 0
    it works out well...thanks

    last question, is it possible to add button on each row? thx
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes - just include the button like you would in a regular table: or whatever.

    Allan
This discussion has been closed.