<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Type Some text in text box and click out of text box </br>
<form class="isAjax" action="workshop\something" data-reload="doSomething">
<input name="keyword" type="text"/>
</form>
<div data-name="doSomething">
</div>
JavaScript
/*
* The following document will be used for basic ajax functionality
* If this file is changed in any way make sure to test existing work
* example: any element with class "isAjax" or "ajax-defer"
*/
/*
* Basic loader html
*/
var loaderBlock = '<div class="text-center ajaxLoader">\n' +
' <div>\n' +
' <span class="fa fa-cog fa-spin" style="color:#3a366b40;"></span>\n' +
' <span class="fa fa-cog fa-spin" style="color:#c0d52f;"></span>\n' +
' </div>\n' +
' <div style="margin-top: -17px;">\n' +
' <span class="fa fa-cog fa-spin-reverse" style="color:#3a366b;"></span>\n' +
' </div>\n' +
' </div>';
/*
* Basic warning html
*/
var warningBlock = '<div>' +
' <div class="text-center">\n' +
' <i class="fas fa-exclamation-triangle text-danger" style="font-size: 3em;"></i>\n' +
' </div>' +
' </div>';
/*
* Add message to error icon
*/
function createErrorIcon(errorMsg){
var block = $(warningBlock)
block.find('div').append('<div>' + errorMsg + '</div>');
return block.html();
}
/*
* Make the ajax call
* action = String action of form or data-action of div
* target = Object of element
* params = Array of parameters
* type = String 'GET', 'POST' etc.
*/
function makeAjaxCall(action, target, params, type) {
console.log('ajaxCalled');
target.html('WE DID SOMETHING!!!' + params);
/* $.ajax({
url:action,
data:params,
type:type,
beforeSend: function( xhr ) {
target.html(loaderBlock);
},
success: function (data) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.