1

I am current using a Ajax function provided by the datatables i only change the url to my own url and the number of columns. This is the error i get

Error Uncaught TypeError: undefined is not a function $(document).ready(function() { alert('working'); $('#example').dataTable( { "processing": true, "serverSide": false, "ajax": { "url": "ViewOwnConsultServ", "type": "POST" }, "columns" : [ {"data" : "lecturename"}, {"data" : "date"}, {"data" : "starttime"}, {"data" : "endtime"}, {"data" : "school"} , {"data" : "team"} , {"data" : "status"} , {"data" : "problem"} ] } ); } ); Here is an my HTML

<table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Lecturer's Name</th>
                    <th>Date</th>
                    <th>Start Time</th>
                    <th>End Time</th>
                    <th>School</th>
                    <th>Team</th>
                    <th>Status</th>
                    <th>Teacher's note</th>
                </tr>
            </thead>
        </table>

I suspected it was something to do with my json but i checked. The below shows an example of my servlet. Does the datatables column should be == to the number of parameter of my json string?

Servlet json

Lastly this is an example of my json output

"data":[{"id":0,"staffid":0,"lecturename":"","starttime":"1pm","endtime":"2pm","roomno":0,"school":"Northland Secondary School","team":"northland","status":"Unconfirmed","date":"01/19/2015","problem":" can i PLEASE CONSULT YOU ON MATTER THAT DONT EXIST"},

Oh i forgot this are my imports

imports

3
  • 2
    Looks like you are not loading dataTables plugin. Commented Feb 5, 2015 at 5:16
  • Oh i just forgot to add the scripts part in just added them, thanks for commenting :) but it is still not working though are the scripts correct? Commented Feb 5, 2015 at 5:19
  • you need to add the second script(jquery library jquery-1.11.1.min.js) before all other script files Commented Feb 5, 2015 at 5:37

1 Answer 1

1

scripts AVOID DUPLICATE SCRIPTS works for me because I re added into a black jsp page with certain js scripts. Because i din't realize there were other scripts at the bottom of the page

Sign up to request clarification or add additional context in comments.

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.