Ajax Call for Every Minute to Server

Scenerio : Here we needs to call a a function to server on every minute,we can use use below code.

$(document).ready(function () {
snooze();
})
function snooze() {
$.ajax({
type: “GET”,
url: ‘URL’,
success: function (data) {
},
complete: function () {
// Schedule the next request when the current one’s complete
setTimeout(snooze, 10000);
}, error: function (xhr) {
},
});

TypeError: $.browser is undefined

Just put below the $.browser code in your js

var matched, browser;

jQuery.uaMatch = function (ua) {
ua = ua.toLowerCase();

var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf(“compatible”) < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];

return {
browser: match[1] || “”,
version: match[2] || “0”
};
};

matched = jQuery.uaMatch(navigator.userAgent);
browser = {};

if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}

jQuery.browser = browser;

Validate a Dynamic Html Table using jQuery

A Dynamic table is above which we will validate.
code to Create Dynamic table is Below:
$(document).ready(function () {

$(‘#btnAdd’).click(function (event) {
event.preventDefault();
AddRow();
});
$(‘#btnRemove’).click(function () {
DeleteRow();
});
$(‘#btnsubmit’).click(function () {
return validate();
});
});
function AddRow() {
$(‘#tblXml’).hide(“fast”);
var id = document.getElementById(‘tblXml’);
var rowCount = id.length;
var row = id.insertRow(rowCount);
// cell 1
var cell1 = row.insertCell(0);
var element1 = document.createElement(“input”);
element1.type = “text”;
element1.name = “Name”;
cell1.appendChild(element1);
//cell 2
var cell2 = row.insertCell(1);
var element2 = document.createElement(“input”);
element2.type = “text”;
element2.name = “Mobile”;
cell2.appendChild(element2);
//cell 3
var cell3 = row.insertCell(2);
var element3 = document.createElement(‘select’);
element3.type = “option”;
element3.name = “Fruit”;
element3.options[0] = new Option(‘-Select Fruit-‘, ‘0’);
element3.options[1] = new Option(‘Apple’, ‘2’);
element3.options[2] = new Option(‘Guava’, ‘3’);
element3.options[3] = new Option(‘Mango’, ‘1’);
cell3.appendChild(element3);
$(‘#tblXml’).show(“fast”)
}
function DeleteRow() {
if (document.getElementById(‘tblXml’).rows.length > 2) {
$(‘#tblXml’).hide(“fast”)
document.getElementById(‘tblXml’).deleteRow((document.getElementById(‘tblXml’).rows.length – 1))
$(‘#tblXml’).show(“fast”)
}
}

Code For Validate Dynamic Table on Submit Button Click

function validate() {
var tbl = $(‘#tblXml’)
tbl.find(‘tbody tr:not(:has(th))’).each(function (index, row) {
if ($(row).find(‘input[name$=”Name”]’).val().trim() == ”) {
//alert(“Enter Name !!”);
$(row).find(‘input[name$=”Name”]’).css({ ‘border’: ‘1px solid red’ });
count += parseInt(count + 1);
return false;
}
if ($(row).find(‘input[name$=”Mobile”]’).val().trim() == ”) {
//alert(“Enter Mobile !!”);
$(row).find(‘input[name$=”Mobile”]’).css({ ‘border’: ‘1px solid red’ });
count += parseInt(count + 1);
return false;
}
if ($(row).find(‘select :selected’).val() == 0) {
alert($(row).find(‘select :selected’));
$(this).parent().css({ ‘border’: ‘1px solid red’ });
count += parseInt(count + 1);
return false;
}
});
if (parseInt(count) > 0) {
return false;
}
else {
SaveDetails();
}

}