ajax passing args in URL?

ajax passing args in URL?

ChrisMiamiChrisMiami Posts: 7Questions: 3Answers: 0
edited September 2016 in Free community support

I have a web service that was build to serve the data that my table requires. It's signature is https://host/app/{arg1}?arg2&arg3.

None of the examples that I see in the ajax|Option docs show how to use a RESTful URL like this. The {arg1} path argument needs to come from a local API call. The arg2 and arg3 arguments can be null on first load, but should be made available for the user to adjust what data is being viewed.

Should I not try to use the ajax: option and instead use data: and populate with a JS function that returns the JSON from the WS?

I'm guessing there's no built-in API to create filters that will re-query the data source, so I'll have to create UI that looks like it belongs with the data. My biggest question is: how do I get the path argument into the ajax path at run time?

I am assuming that it's probably a pretty common use-case.

Answers

  • ChrisMiamiChrisMiami Posts: 7Questions: 3Answers: 0

    I solved this by using the jQuery $.ajax() method and then in its success callback, I have these lines of code:

        table.clear();
        table.rows.add(dataSet).draw();
    

    I couldn't find a way to do it using the built-ins of Datatables.net.

This discussion has been closed.