This is a very basic question, I think I ask very tough questions on here and they never get answered… Let me break it down to its simplest possible components and work up from there…
I have a view which requires user information to be entered in… on submit, this view calls a controller, which will give me the data that I need to put back on to this SAME view… How do I get get that data back onto my view without calling the same view again at the end of the execution of the controller…?
Here is what I have so far (Jquery function)…
$(function () {
$("#DemoGraphSubmit").click(function (e) {
e.preventDefault();
var data = [];
$.getJSON("/PatientACO.aspx/SearchByDemographic", null, function (data) {
data = $.map(data, function (item, a) {
return "<option value=" + item.Value + ">" + item.Text + "</option>";
});
$("#PatientListToAdd").html(data.join(""));
});
});
});
submit button and select list that I want populated
<div >
<select id="PatientListToAdd">Add Patient</select>
</div>
While my example doesn’t exactly mimic your design (you might be using a page method or some questionable routing), but as long as
/PatientACO.aspx/SearchByDemographicis returning JSON, you should be able to apply this code. Populate theList<ListItem>collection with your data as needed and return JSON.I added an action called SearchByDemographic, and you will see in my jQuery further down that I use it instead of your URL. However, it still accepts POST requests and returns JSON.
Then, my jQuery is slightly modified to use
$.ajaxwhich is just longhand for$.getJSONand it allows a few more options.