Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
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

 Answers
3

Try,



URL: localhost:1234/myProject/WebApp/Data?accountCode=+stringAccountCode


Appending number of parameters you want example



?accountCode=+stringAccountCode+&aa=+someAccount

[#72122] Tuesday, March 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellisw

Total Points: 625
Total Questions: 92
Total Answers: 88

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
ellisw questions
Mon, Aug 23, 21, 00:00, 3 Years ago
Fri, Nov 20, 20, 00:00, 4 Years ago
Sat, Jun 20, 20, 00:00, 4 Years ago
Tue, Apr 21, 20, 00:00, 4 Years ago
;