Getting data back from database after an ajax post submit
- by sslepian
I've got a web page where the user can add a new item to a category and that item is saved to the database. However, the ID of the item is an identity value for the database table, so I don't know what the ID will be, and I need this ID so that the user can edit the item later.
I'm using ajax to make a POST submit:
$.ajax({
url: 'TumourGroup/CreateSub',
type: "POST",
data: {'pos': index, 'text': text }
});
This is linked to an MVC model with three fields, ID, pos, and text. Is there a way for me to get the ID that's generated on POST submit by having CreateSub(int index, string text) return something?