Experiences with jsonp in Editor?

Experiences with jsonp in Editor?

kwssaatkwssaat Posts: 2Questions: 1Answers: 0

Hi folks,
the following datatables example with jsonp support is working fine: https://datatables.net/examples/server_side/jsonp.html However when I try to implement editor with REST services via jsonp I can't get it to work. How should I configure my editor. Only add a dataType attribute to the ajax part? Or do I need to specify a success function as well?

Thanks in advance,
Christoph

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Hi Christoph,

    Are you using the Editor PHP libraries? If so, you will need to do something like:

    echo $_GET['callback'].'('.json_encode(
        $editor->data()
    ).');';
    

    Also set the dataType option for the ajax object. And finally remember that JSONP only works with GET.

    Allan

  • kwssaatkwssaat Posts: 2Questions: 1Answers: 0

    Hi Allan,
    the last point was the right one. Restricted JSONP to Get only so everything was fine. Gonna try out CORS later on.

    Thank you, Christoph.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Sounds great - let me know how you get on with it!

    Allan

This discussion has been closed.