Create JSON string for AJAX
Something about this that makes me feel a little messy, what's the appropriate way to pass values to a data field?
I am currently doing this: var jsonstring = "{id:" + id + "}";
<script type="text/javascript">
function CompleteCB(id) {
var jsonstring = "{ id: " + id + "}";
$.ajax({
type: "POST",
url: "/internal/completeholters.aspx/CompleteCB",
data: jsonstring,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
$("#row" + id).fadeTo("fast", 0.33);
}
});
}
</script>
+3
source to share