How do we implement the AJAX HTTPObject to update a textbox on click of a button in ASP.Net and javascript. Would the same code apply if the updation would be done on a datagrid ? A implementation of HTTPObject that I read is given at http://jai-on-asp.blogspot.com/2009/12/ajax-classical-way.html
views:
77answers:
1
+4
A:
Please don't reimplement this. Find a nice javascript toolkit like jQuery (or Prototype, MooTools, Dojo, ...) that has an AJAX implementation and use it. You'll save yourself a lot of grief with cross-browser support if you use an existing implementation that's already been well tested in practical usage.
Example using jQuery:
$('#myButton').click( function() {
$.ajax({
url: '/example.com/findsomething',
dataType: 'json',
success: function(data) {
$('#myTextBox').val( data.value );
}
});
});
This assumes that the value is retrieved via a GET request and is returned in JSON object with the following format: { value: 'the actual value' };
tvanfosson
2009-12-31 18:15:52