I’ve got some Ajax code with calls a WebMethod from within my back-end code and now want to be able to databind the information it receives to a repeater.
Here’s my Ajax
$.ajax({
type: "POST",
url: "default.aspx/Call_Car",
data: '{ Ref: "MD12355"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var cars = msg.d;
$.each(cars, function(index, car) {
$('.test').text(car.PICKUP);
$('.test2').text(car.SUPPLIER);
});
}
});
At the moment it is writing the fields PICKUP and SUPPLIER to my labels but ideally i want it to be able to databind my repeater with all the data.
Here’s the response I get back from this call
{"d":[{"SUPPLIER":"Magos Car Hire","PICKUP":"Funchal Airport"}]}
Is it possible to do this?
Thanks
You cannot, a repeater binds on the server side, and you are returning client side data.
You can use one of the jQuery grids or a variety of other grids (kendoui im particularly fond of from telerik)
Or you could request the page from the server that contains the data and grid and load that via ajax.
This is addressed in a bit more detail here:
Bind Data to Repeater using Ajax