Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ignore a Query String when using ajaxComplete (settings.url)

I’m using ajaxComplete to catch AJAX requests, but only problem is I cant catch the /cart.js because there is always a random Query String.

ex- ‘/cart.js?_=1324346569

How can I tell this ajaxComplete to ignore query strings so my code picks up on just ‘/cart.js’?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My code –

$(document).ajaxComplete(function(event, xhr, settings) {
    if (settings.url === "/cart.js") {
        console.log('caught cart.js even tho it has these query parameters');
    }
});

Thanks very much!

>Solution :

if (settings.url.includes("/cart.js")) {
  // ....
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading