ajax url file path question

ajax url file path question

AdamsKingmanAdamsKingman Posts: 3Questions: 1Answers: 0
edited May 2015 in Free community support

Hi Everyone, I have a silly question but kind of bother me.
So I have the following code:
What I want is Change the File Path from "data.json" to another folder path like "../Data/data.json"

But it seems like Datatables alert error to me, I suspect it's the "url" didn't find the proper file path? I just simply want to put the actual json file in another folder.
Please advice. Thank you.

$('#example').dataTable( 
{  "ajax": 
           {    "url": "data.json",    
                "dataSrc": "tableData"  }} 
);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    I don't understand what you mean by "Datatables don't allow" I'm afraid. Can you not just modify the configuration text? If that doesn't work for you, please link to a test case (as required in the forum rules) so we can try to help debug it.

    Regards,
    Allan

  • AdamsKingmanAdamsKingman Posts: 3Questions: 1Answers: 0

    Hi Allan, thank you for your reply. I have updated my question.

    Yes I would love to post you a link, I know jsfiddle, but I don't know how it can read file path from a local path ../Data/data.json.
    It just, I want to put the json file in another folder. And Datatables generate error for it.

    From: C:\inetpub\wwwroot\WebSite_ABC\data.json
    To: C:\inetpub\wwwroot\WebSite_ABC\App_Data\data.json

    Please advice. I Appreciated it.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Answer ✓

    You can't do that unfortunately. That is not a DataTables issue but rather a browser security feature. Being able to load files from a user's computer via Ajax would be a massive security hole.

    Allan

  • AdamsKingmanAdamsKingman Posts: 3Questions: 1Answers: 0

    oh yeah that's true. I didn't think of that. Thanks, you are right.

This discussion has been closed.