It’s never been easier to add Ajax to any website. In fact it’s flattering common to build whole websites based around Ajax requests called Single-Page Apps (or SPAs).
How to Create An Ajax-Based HTML5/CSS3 Contact Form
[series_html5css3] Contact form is lethal essential for any website, as it acts as a follower that passes the…Read more
However this has always compulsory a bit of jQuery and some technical wrangling to update page content. If we only need some basic Ajax functionality we can use intercooler.js to brew this right into your HTML.
Intercooler lets we write HTML attributes that natively enclose Ajax ask URLs. When users click certain links we can foreordain that Ajax requests run instead of a normal click action.
This all relies on HTML5 data-* attributes such as
ic-post-to. You can supplement this charge to a symbol or an anchor link, and it’ll automatically bond into jQuery for an Ajax POST request.
There’s indeed a page full of these attributes on a plugin website. Here’s a bit of sample code to see how it looks:
a ic-post-to="/button_click"Click Me!/a
This would send an Ajax POST ask to a URL
/buton_click, and load a response into a enclosure element. Intercooler is a flattering elementary library and impossibly absolute once we know how it works.
Granted this won’t solve all your Ajax problems since it can’t auto-update other areas of a page. It also can’t attach too many tradition features but negligence down a page, so a minute SPA should unequivocally use tradition Ajax code.
Intercooler.js offers a more semantic approach for essay Ajax code so that it loads and even offers a internal fallback.
To install intercooler we only need a copy of jQuery along with a copy of a intercooler library that can be found on GitHub. You can even test but downloading any files by regulating a jQuery CDN and a internal Intercooler CDN.
Put both into a
script tab in a header of your page, and afterwards only place a HTML attributes wherever we want!
Take a look during a demos page to see a full list of demos we can fondle with. we generally like a ‘Click to Edit’ demo since it shows accurately what’s probable and how distant we can take this plugin.
If you’re meddlesome in learning more check out a reference guide full of intercooler HTML attributes. Each one performs a opposite action so it’s essential to investigate them all and see what fits best for your scenario.
Naturally, we can find all a source code for giveaway on GitHub along with a brief designation guide.