Category: javascript
WordPress AJAX using Backbone JS
WordPress has default backbone js included and we can use backebone.js for ajax in WordPress. We just need to include it. I’ve created an example of ajax using backbone. All you need to do is check the following link. https://github.com/BhargavBhandari90/wp-tips/tree/main/wp-backbone-ajax
Abort all running ajax on click jQuery
There may be times you want to stop ajax request on some event like on click, hover etc… In my case, I wanted to run an ajax on click, but I wanted to cancel all other ajax request to be stopped before my ajax. So after lots of finding I found one solution here. I…
Change URL without reloading page using Javascript
Change URL without reloading page using Javascript
Need Help… How to use trigger event in backbone?
So I have a script where I am trying to trigger click event by jQuery. Here is the syntax $( ‘#selector’ ).trigger( ‘click’ ). But that will work if the click event function is written in jQuery. What if click event is written in backbone? How can I trigger click for that? If anyone has…
Alternative for URLSearchParams
IE doesn’t support “URLSearchParams”. So sometimes your script will not work in IEs. So the alternative for the “URLSearchParams” is as below. window.getUrlParameter = function( keyword, query_string ) { keyword = keyword.replace(/[\[]/, ‘\\[‘).replace(/[\]]/, ‘\\]’); var regex = new RegExp( keyword + ‘=([^&#]*)’); var results = regex.exec( query_string ); return results === null ? ” :…