javascript - jquery form submission in new window -
i want set header information , cookies form submission using $('#formid').submit(); javascript code. of site says setrequestheader working on ajax form submission. can not use ajax method submit form.
my javascript code is
$(document).ready(function(){ $("#leftnav a").click(function(event){ event.preventdefault(); href = $(this).attr('href'); $("#dynamicform :input").remove(); var querystringarray = href.split('?')[1].split('&'); $("#dynamicform").attr("action", href.split('?')[0]); $.each(querystringarray, function(index, value) { var elementarray = value.split('='); if(elementarray[0]=='methodtype') { $("#dynamicform").attr("method", elementarray[1]);} $('<input>').attr({ type: 'hidden', value: elementarray[1], name: elementarray[0] }).appendto('#dynamicform'); }); usagelogsajax(href.split('?')[0],'ncrtester'); xhr.setrequestheader('x-test', 'three');xhr.setrequestheader('x-shashi', 'three'); $('#dynamicform').submit(); }); }); function usagelogsajax(url, user) { $.get("usagelogs.php?url="+url+"&username="+user,function(responsetxt,statustxt,xhr){ if(statustxt=="success"); //alert("usagelogs created successfully!"); if(statustxt=="error"); //alert("error: "+xhr.status+": "+xhr.statustext); }); }
and page have link http://sitename.com/autologinsl3?readform=&userid=userid&methodtype=get&pwd=passowrd
how can achieve requirements.
thanks
i think looking target-attribute of form (see mdn). if set target="_blank" form submitted , result shown in new window.
Comments
Post a Comment