There's something about this that makes me feel slightly dirty, what's the appropriate way to pass values to the data field?
Currently I'm 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>
According to the AJAX model, web applications can send and retrieve data from a server asynchronously without interfering with the display and the behavior of the existing page. Many developers use JSON to pass AJAX updates between the client and the server.
Create target "JSON object Mapper" object class file according to the business requirements. Create a "Controllers\HomeController. cs" file with default Index method and GetData(...) method with string type input query parameters for Ajax call with following lines of code i.e.
Description: Takes a well-formed JSON string and returns the resulting JavaScript value.
leave it as an object and call JSON.stringify()
var obj = {};
obj.id = 22;
JSON.stringify(obj); // "{"id":22}" a JSON formated string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With