Datatables Serverside OPTIONS request.

Datatables Serverside OPTIONS request.

RossZARossZA Posts: 3Questions: 1Answers: 0

I am finding that when I am doing an Ajax GET to retrieve my data on first load Datatables is also doing an OPTIONS request.

I have been reading through the manual but I cannot find why it is doing this and how to turn it off.

I also have the scroller extension installed but I don't believe it has anything to do with that.

DataTables 1.10.20

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    That's not happening in this example here. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • RossZARossZA Posts: 3Questions: 1Answers: 0

    Thank you Colin, your response has made me dig a little deeper,

    Though watching the network on chrome, like your example no OPTIONS request is sent, but my logging on my API shows that there is one.

    If I recreate the calls through postman no OPTIONS request is sent, so I still need to do some more digging to find out what is happening.

  • RossZARossZA Posts: 3Questions: 1Answers: 0

    And the Answer :

    https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

    "
    Preflighted requests

    Unlike simple requests (discussed above), "preflighted" requests first send an HTTP OPTIONS request header to the resource on the other domain, in order to determine whether the actual request is safe to send. Cross-site requests are preflighted like this since they may have implications to user data. In particular, a request is preflighted if:

    It uses methods other than GET or POST. Also, if POST is used to send request data with a Content-Type other than application/x-www-form-urlencoded, multipart/form-data, or text/plain, e.g. if the POST request sends an XML payload to the server using application/xml or text/xml, then the request is preflighted.
    It sets custom headers in the request (e.g. the request uses a header such as X-PINGOTHER)
    "

    Credit to : https://stackoverflow.com/questions/1256593/why-am-i-getting-an-options-request-instead-of-a-get-request

This discussion has been closed.