I have this:
var searchString = action +  ?  + 'search=' + search + '&filter='
the action variable could either already have a ?parameter or could not have one.
therefore I need to test action if it already contains a ? and if so append &search. Otherwise I need to use ?search
Any idea how to solve that in an easy manner?
var searchString = action + (action.indexOf('?') != -1 ? '&' : '?') + 'search=' + search + '&filter=';
                        var searchString = action + ((action.indexOf('?') == -1) ? '?search=' : '&search=');
Or you can use the jquery Query Plug-in http://plugins.jquery.com/project/query-object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With