sAjaxSource

sAjaxSource

koolkatwebdesignskoolkatwebdesigns Posts: 6Questions: 0Answers: 0
edited May 2011 in General
I have a server based xml file that I would like to use as a data source. I can easily use php and return the correct json to datatables. The actual number of records I return is small - about 120 so I would like to be able to sort, filter and paginate on the client. I realize that this is not supported in datatables so I was wondering how to turn the server-side xml into a client-side json file that I could use?

Thanks.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    A Google search for "php xml to json" (of course you might not be using PHP, but the same will apply I'm sure) comes up with quite a lot of hits for how this can be done - for example: http://www.ibm.com/developerworks/xml/library/x-xml2jsonphp/ .

    Allan
  • koolkatwebdesignskoolkatwebdesigns Posts: 6Questions: 0Answers: 0
    Thank you for your answer. I understand how to convert XML to json in PHP but was wondering how to get it into a client side file.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Can you not just echo it?

    [code]
    <?php echo xmlToJson( $xml ); ?>
    [/code]
    Allan
  • koolkatwebdesignskoolkatwebdesigns Posts: 6Questions: 0Answers: 0
    Won't that just put it into standard output such as the monitor? I would like to create a client side Ajax file such as in your great examples so I can use the client side processing.


    Thanks.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    That script snippet will output to the monitor if you just stick it in the HTML where it will be rendered - but if you make an Ajax request fir the file which holds that script - that will be treated like json - just as my examples are.

    Allan
  • koolkatwebdesignskoolkatwebdesigns Posts: 6Questions: 0Answers: 0
    Got it working. thanks
This discussion has been closed.