Hey,
I’m wondering which would be faster to retrieve the data as JSON and let javascript sort it out for me or just store the HTML in a variable and let PHP echo it?
For example I currently something like this
$.ajax({
type: 'POST',
data: 'id=' + id,
url: 'page.php',
success: function (html) {
$('.section').html(html);
}
});
But if I did it through JSON would it like so:
$.ajax({
type: 'POST',
url: 'page.php',
data: 'id=' + id,
dataType: 'json',
success: function(d) {
var html = '';
for (i=0;i<=d.length;i++) {
html += '<div class="1">'+d[i].id+'</div> <div class="2">'+d[i].name+'</div> <div class="3">'+d[i].ph+'</div>';
}
}
$('.section').html(html)
});
Would that give me a performance boost? Or is it just another one of doing things?
thanks for any input!