Datatables Is Adding a Query String to AJAX URL

Datatables Is Adding a Query String to AJAX URL

lsankeylsankey Posts: 5Questions: 2Answers: 0

I getting the following error from my AJAX call (below), but I am only setting the url to https://coincap.io/front/. I did not add the query string ?_=1512079436939. I don't know why it's getting append to my url.

jquery.js?ver=1.12.4:4 GET https://coincap.io/front/?_=1512079436939 524 ()
send @ jquery.js?ver=1.12.4:4
ajax @ jquery.js?ver=1.12.4:4
sa @ datatables.min.js?ver=4.9.1:48
ga @ datatables.min.js?ver=4.9.1:60
e @ datatables.min.js?ver=4.9.1:104
(anonymous) @ datatables.min.js?ver=4.9.1:104
each @ jquery.js?ver=1.12.4:2
each @ jquery.js?ver=1.12.4:2
m @ datatables.min.js?ver=4.9.1:94
h.fn.DataTable @ datatables.min.js?ver=4.9.1:176
(anonymous) @ coincapapi.js?ver=4.9.1:125
i @ jquery.js?ver=1.12.4:2
fireWith @ jquery.js?ver=1.12.4:2
ready @ jquery.js?ver=1.12.4:2
K @ jquery.js?ver=1.12.4:2
(index):1 Failed to load https://coincap.io/front/?_=1512079436939: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://munnii.me' is therefore not allowed access. The response had HTTP status code 524.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓
    <?php _=1512079436939 ?>

    Has do do with disabling cache for the ajax request:
    http://api.jquery.com/jquery.ajax/

    Look for the cache option for more details. Don't think it has anything to do with the error though. If desired you can change the request type to POST to eliminate the _=1512079436939 from being appended to the URL.

    The error has to do with cross domain communications. This is not a Datatables specific issue. A google search of the error message provides lots of results which should help you to fix the issue.

    Kevin

  • lsankeylsankey Posts: 5Questions: 2Answers: 0

    Figured out the problem and why "?_=1511996069966" is being added to the URL on the AJAX call. I added some code for Facebook login and this setting for jQuery is the cause of the problem. Turns on the cache for AJAX calls and adds a query string to the end of the URL.

    jQuery.ajaxSetup({ cache: true });

This discussion has been closed.