I have a function called UpdateBoatTable, which is supposted to update a HTML Template via jsRender. The function looks like following:
$.fn.UpdateBoatTable = function()
{
$.ajax({
url: "backend/boat.php?a=show",
datatype: "json",
success: function(data)
{
alert(data);
$("#BoatList").html
(
$("#BoatTemplate").render(data)
);
}
});
}
The MessageBox (alert(data)) is returning the following value:
[{"BoatID":"2","RegNo":"Registration Number","BoatName":"Boatname","BoatType":"Type"}]
But rendering the data to a template fails.
If i am going to hard code the json data, it works…
$.fn.UpdateBoatTable = function()
{
$.ajax({
url: "backend/boat.php?a=show",
datatype: "json",
success: function(data)
{
var data = [{"BoatID":"2","RegNo":"Registration Number","BoatName":"Boatname","BoatType":"Type"}];
alert(data);
$("#BoatList").html
(
$("#BoatTemplate").render(data)
);
}
});
}
Can you tell me why it is only working if it is hardcoded?
Thank you very much!
Typo,
datatype: "json",should bedataType: "json",