87
rated 0 times
[
89]
[
2]
/ answers: 1 / hits: 29114
/ 10 Years ago, thu, march 6, 2014, 12:00:00
I have a function which currently passes an account code (derived from a combo box) to the server. Currently it does this by sending the request in the body - I need it to send as a URL parameter. So for example the URL should be:
localhost:1234/myProject/WebApp/Data?accountCode=Full
Assuming full is selected.
My code below works as a request body but my attempts to amend it to submit as a 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 at using $.param but couldn't get anything to work and also read on other questions about using $.get
but when I change my code above to a GET
i get an error
Request method 'GET' not supported
- the server is expecting a POST request. Any way i could achieve this?
Thanks
More From » jquery