jQuery form POST method is not working

67 Views Asked by At

I am using jQuery 1.7.2 and trying below code but it always sending data as Query String, I am wanted it to send as POST. What I am doing wrong?

HTML:

<form id="Test" method="post">

    <input type="submit" value="Search" id="btnTest" />
  </form>

JQuery:

$(document).ready(function () {
    $("#btnTest").click(function () {
      var a = "http://xxx.xxx.com/xxx.aspx?target=/IBE.aspx&pub=/kw/English&Tab=1&s=&h=&header=true&footer=true";
      a += "&tid=SB&dpSortBy=0&selacity1=DXB&selddate1=22-Jul-15&seldcity1=KWI&seladate1=25-Jul-15&selAdults=1&selcabinclass=0&selchildren=1&selinfants=1";
      $("#Test").attr('action', a);
      $("#Test").attr('method', 'post');
      $("#Test").submit();
    });
  });
0

There are 0 best solutions below