javascript - Passing a variable to URL parameters using JQuery POST -
i have function passes account code (derived combo box) server. sending request in body - need send url parameter. example url should be:
localhost:1234/myproject/webapp/data?accountcode=full
assuming full selected.
my code below works request body attempts amend submit url request have failed.
accountselected: function () { var saccountcode = $("select#accountcombo").val(); var stringaccountcode = saccountcode.tostring() console.log("account is: " + stringaccountcode); var myurl = "webapp/data"; $.ajax({ url: myurl, type: "post", data: { "accountcode": stringaccountcode }, datatype: "text", })
i have been looking @ using $.param couldn't work , read on other questions using $.get
when change code above "get"
error "request method 'get' not supported"
- server expecting post request. way achieve this?
thanks
try,
url: "localhost:1234/myproject/webapp/data?accountcode="+stringaccountcode
appending number of parameters want example
?accountcode="+stringaccountcode+"&aa="+someaccount
Comments
Post a Comment