javascript - windows.location.href change results in POST, expecting GET -


the following method called 2 different buttons's onclick event:

this.changesearch = function(obj, $tag) {     var url = jquery('#admin_url').val() + '/tools.php?page=cemeteriat&cempage=' + $tag;     window.location=url;     return; }; 

in 1 instance, whether form populated or not, button press results in expected call. in other, if form populated, instead of expected url, post executed url assigned in action attribute of form. the...

i've traced code, , both times url above assigned same value! have tried using document.location, window.location, , window,location.href no change in behavior. not seem t browser specific.

what cause assigned of windows.location result in post of form instead of expected get?

it's because 1 of buttons submit button form, it's getting submitted , it's never getting code you're showing.

you should hook form's submit event , call event.preventdefault(); cannot prevent form submission click handler submit button.

alternatively, can make button not of type submit.

another option handle submit event , change form submit handler point correct url , method of submission


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -