I am having a hard time with my comiler passing variables to my .Post method in Jquery…
$(function () {
$("#DemoGraphSubmit").click(function (e) {
e.preventDefault();
var form = $("#DemoGraphID").serialize();
var PopID = <% =PopID %>
var options = [];
var serializedForm = form.serialize();
$.post("/PatientACO/SearchByDemographic", {PopID,form}, function (data) {
options = $.map(data, function (item, i) {
return "<option value=" + item.Value + ">" + item.Text + "</option>";
});
$("#PatientListToAdd").html(options.join(""));
});
});
});
The second parameter of the $.post() method… It keeps telling me I need a “:”… How does one set up variables and pass them to functions in jquery?
The data that you pass to post method can be a well formed json object or a querystring param as below