Reputation: 853
I am trying to return an html table from a asp.net web service but can not figure out how to get the string that is returned to be actual html. Here is my jquery call...
$.ajax({
type: "POST",
url: "UserService.asmx/PersonTable",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(obj) {
alert(obj);
$('#tblPeople').text(obj.d);
},
error: function() {
alert("error");
}
})
it returns the string in the format I want but just writes out the string to the screen which is the string representation of an html table. How do I get the actual Html table to render?
Upvotes: 0
Views: 7115
Reputation: 22418
Since you are returning HTML you need to drop the JSON parts of your call and use the HTML() call rather than text()
$.ajax({ type: "POST",
url: "UserService.asmx/PersonTable",
data: "{}",
//dataType: "json",
//contentType: "application/json;
charset=utf-8",
success: function(obj) {
alert(obj);
$('#tblPeople').html(obj.d);
},
error: function() {
alert("error");
}
});
Upvotes: 1
Reputation: 37751
change $('#tblPeople').text(obj.d);
to -> $('#tblPeople').html(obj.d);
Upvotes: 10
Reputation: 853
Figured out he issues. I was using $('#tblPeople').text(obj.d); instead of $('#tblPeople').html(obj.d);
Upvotes: 0