Reputation: 16968
I have a form that is currently being loaded via AJAX. Ideally I would use the jQuery load()
method, however, this request is slightly more complex as I also need to retrieve individual properties instead of just one large HTML chunk.
So, my script looks something like this (simplified):
$.ajax({
url: url,
dataType: 'json',
success: function(data){
// Set the width of the form
$('.form').css({
width: data.width
})
// Load the form into the popup
$('.form').html(data.html);
}
});
I am unsure whether including my HTML markup in the JSON response is such a good idea...
I am of course aware that I could build the markup using javascript, however, as there are several forms and all of which are quite large, it it much easier to build the form server side. Not to mention the fact it makes it much easier to debug/develop/maintain...
Furthermore, my site is currently VERY javascript heavy so I would like to minimise as much of the js needed as I possibly can.
Upvotes: 2
Views: 1369
Reputation: 3411
Upvotes: 4