Getting generated HTML via AJAX is a bad practice? - ajax

I can receive JSON.
Is this a bad practice? And if so, who said that? W3C?
No personal opinion, please
Referencies links will be good.

The idea being that HTML is bigger than json, so where possible, update the existing page using json content.

Related

Readable Django ajax request errors

What is the best way to have readable ajax views errors in Django?
I can read them in Chrome's Response tab but only as plain text and a lot of information that is available on Django's standard error page is missing.
I have found the Django-Ajaxerror and sort of fixed it to run under Windows but it still doesn't work. How does everybody manage this problem in Django world?

how to achieve the http://wearehunted.com effect

I am looking for a way of replicating what the site in the title of this question does. That is, via ajax, changing a part of the page. But, I could not figure out how to change the URL as these things happen.
So, please, help me achieve the effect of url changing on ajax page/change.
Thank you.
(edit ** question rewritten as is appears it was not written well enough, sorry)
What you are looking for is AJAX basically updating only parts of a HTML page. Please google for AJAX tutorials. Here is a simple one
Something like Jquery Tabs also do this.
It seems like you want the URL to change. This is the basic trick to have history for ajax pages

Implementing Django Templates and jQuery Templates Together

I'm working on a website that uses AJAX to retrieve data from the server and display it on the page. Django renders the initial page content using its template engine (so it will be indexed by search engines). When the user takes an action, jQuery fetches the new data via AJAX and the response is returned as JSON. I would like to have jQuery render this new content without violating the DRY Principle. Therefore I would like to use a templating engine that is "shared" between Django and jQuery. I've been running in circles trying to find the best solution but always seem to run into a road block.
Has this already been done? Here are the options I have thought of:
Use regular expressions to transform the Django template into correct jQuery template syntax, and render it in its raw form to the page. jQuery will then pick it up and use it to render the new data.
Extend the jQuery template engine to recognize the Django template syntax, again rendering the raw Django template to the page for jQuery to use.
Has this been successfully done before? Either way seems like a lot of work for anything but the simplest of Django templates because of the plethora of Django tags and filters that would need accounted for.
Your best bet is to pick a template language that has both Javascript and Python support, and use that everywhere.
As far as I know, Mustache is your best bet.
I haven't found a perfect solution since I asked this question, but for the sake of development time I resorted to sending back both JSON and HTML in the AJAX response. This way the django templates still perform the HTML generation, but javascript is still free to utilize the data without having to parse the HTML.
I am sending approximately twice the data over the network, but I'm going to live with it until my application grows to the point where a smaller response is beneficial. At that point I will probably look into something like Mustache as Rob mentioned.

Could someone explain hash tag usage for deeplinking ajax applications?

I am currently trying to full appreciate how and when to use hash tags in urls when building an ajax powered website. There seems to be a distinct lack of reading material on the web regarding this technique and as such I don't feel like I've got a good handle on it.
Could someone explain in the simplest terms how the hash tag can be used in urls to enable things like loading pages via ajax.
Thanks
You might want to take a look at Google's Making AJAX Applications Crawlable website.

Using Firebug to send form data

Is it possible to send AJAX data with params, that aren't in the URL?
I have a script that gets information from a form, and the server uses POST and not GET.
I noticed the possibility in FireBug to send the params only in the URL.
In case it's impossible, is there another program that might help me with that?
https://addons.mozilla.org/en-US/firefox/addon/3899
Simple and FireFoxy..
Have also a look at Fiddler.
For that I use LiveHTTPHeader addon. It offers you nice record/replay facilities and replay also for HTTP POST style. You can also modify the payload.
It's possible.
In XMLHttpRequest.send(); you can put POST data

Resources