0

Hi I am trying to implement the datatables example and got blocked while accessing sample data.

Here is the fiddle where I got blocked

Here is data tables working example from site

$(document).ready(function() {
    var table = $('#example').DataTable( {
        "ajax": "../ajax/data/objects.txt",
        "columns": [
            {
                "class":          'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "salary" }
        ],
        "order": [[1, 'asc']]
    } );
3
  • do you haVE ANY DATA inside ../ajax/data/objects.txt ?? Commented Jun 9, 2014 at 6:01
  • instead of .txt file I want to access mock data. Commented Jun 9, 2014 at 6:17
  • first chose which datasource approprite for you Commented Jun 9, 2014 at 6:19

2 Answers 2

2

You are using ajax data source from a text file and again want's to show data from javascript source. then you have to try like https://datatables.net/examples/data_sources/js_array.html as sakir suggested there are four data sources for data table. use any of them as per your requirement

//see here
https://datatables.net/examples/data_sources/
https://datatables.net/examples/data_sources/js_array.html
Sign up to request clarification or add additional context in comments.

Comments

0

the link you have gave,there are different datasource types

some o them like this.

Data sources

    HTML (DOM) sourced data
    Ajax sourced data
    Javascript sourced data
    Server-side processing

I guess you need to use Javascript sourced data to run your example properlly as you desribe it as a javascript data

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.