I'm using POST to submit data to the server, this error appears in the console:
POST localhost/myProject/webapp/setAccount 400 (Required String parameter 'accountID' is not present)
The user will select from a combo box an account ID and this is what should be passed in the post.
Here is my code:
accountSelected: function () {
var accountSelected = $("#accountcombobox").val();
console.log("Selected Account: " + accountSelected);
var myUrl = "webapp/setAccount";
$.ajax({
url: myUrl,
type: "POST",
data: accountSelected,
dataType: "json",
contentType: "application/json"
})
.done(function (data) {
console.log("Response " + JSON.stringify(data));
})
}
The first console.log shows the selected account ID as expected so i know the value is correct. I want to pass this value to the POST request, which is what i thought i was doing but cannot seem to get it to work.
EDIT
Thanks for the responses but none of the answers seem to be working for me, still the same error.
I'm also using Marionette and Backbone, could this effect it?