JellyRekt
Need help connecting AJAX to Controller to DAL
>2 things, I have a value from the current table, but the insert statement is asking for the new value. So if current value is 3, now it needs to be 4 when inserted to db
I'm not sure what you mean here. What value do you have and what are you trying to insert?
123 replies
Need help connecting AJAX to Controller to DAL
I'm pretty confident that will get your values all coming through to the model. When you submit a vanilla HTML form, the default handler maps the form controls automatically to a JSON object, but when you use ajax, you have to describe the body explicitly.
123 replies
Need help connecting AJAX to Controller to DAL
Ah!
data
is the body of the request, in javascript object form. It should look like
Basically, for each property you're trying to add to the model, this is where you map it from the values currently in the form.123 replies
Need help connecting AJAX to Controller to DAL
Interesting, I must be wrong then! I've had a similar problem before and that was how I figured out what was going on. We're looking for the key that is NOT going through, though, which is the one that is set to zero in the Model that's passed to the create action.
123 replies
Need help connecting AJAX to Controller to DAL
See how it says
name="x.PrimaryID1"
? It should be PrimaryID1
, no x. Right now your request body is going to look like
So there's probably a problem with how the form element is being generated. I'll have to look back at your code again123 replies
Need help connecting AJAX to Controller to DAL
No worries! If it's a web page, likely it's using the "name" property of the form control as a key in the request body. If you right click that dropdown and inspect element, you should be able to see what the "name" is in the HTML that's rendering. You'll want to verify that it matches the property on the model to which you're expecting it to map, but I don't think casing matters.
123 replies