this is my code for InfoPath postback
window.onload = function() {
window.setTimeout(getData, 1000);
}
function getData(){
getEmployee();
getCompany();
window.setTimeout(getData, 1000); //To handle IP's form postback
}
function getEmployee(){
var employee = [];
$().SPServices({
operation: "GetListItems",
listName: "employee",
CAMLViewFields: "",
CAMLQuery:"<Query><Where><Eq><FieldRef Name='Inactive0'/><Value Type='Boolean'>0</Value></Eq></Where></Query>",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
employee.push({label:$(this).attr("ows_Title"),value:$(this).attr("ows_ID")});
});
}
});
$("input[id$='FormControl0_V1_I1_T26']").autocomplete({
source: employee,
minLength: 2,
select: function( event, ui) {
alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.value) : "Nothing selected, input was " + this.value);
$("input[id$='FormControl0_V1_I1_T27']").focus();
$("input[id$='FormControl0_V1_I1_T26']").val(ui.item.label);
$("input[id$='FormControl0_V1_I1_T27']").val(ui.item.value);
event.preventDefault();
return false;
},
focus: function(event, ui){
event.preventDefault();
$("input[id$='FormControl0_V1_I1_T26']").val(ui.item.label);
function getCompany(){
var company = [];
$().SPServices({
operation: "GetListItems",
listName: "company",
CAMLViewFields: "",
CAMLQuery:"<Query><Where><Eq><FieldRef Name='Inactive'/><Value Type='Boolean'>0</Value></Eq></Where></Query>",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
company.push({label:$(this).attr("ows_Title"),value:$(this).attr("ows_ID")});
});
}
});
$("input[id$='FormControl0_V1_I1_T28']").autocomplete({
source: company,
minLength: 2,
select: function( event, ui) {
alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.value) : "Nothing selected, input was " + this.value);
$("input[id$='FormControl0_V1_I1_T29']").focus();
$("input[id$='FormControl0_V1_I1_T28']").val(ui.item.label);
$("input[id$='FormControl0_V1_I1_T29']").val(ui.item.value);
event.preventDefault();
$("input[id$='FormControl0_V1_I1_T28']").val(ui.item.label);
event.preventDefault();
}
in the function getEmployee() and getCompany() i am using autocomplete for the textbxox, for the code windows.setTimeout(getData, 1000), my form gets very slower for every 1 sec it is getting postback , is there anyother solution for postback to make my form speed
window.onload = function() {
window.setTimeout(getData, 1000);
}
function getData(){
getEmployee();
getCompany();
window.setTimeout(getData, 1000); //To handle IP's form postback
}
function getEmployee(){
var employee = [];
$().SPServices({
operation: "GetListItems",
listName: "employee",
CAMLViewFields: "",
CAMLQuery:"<Query><Where><Eq><FieldRef Name='Inactive0'/><Value Type='Boolean'>0</Value></Eq></Where></Query>",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
employee.push({label:$(this).attr("ows_Title"),value:$(this).attr("ows_ID")});
});
}
});
$("input[id$='FormControl0_V1_I1_T26']").autocomplete({
source: employee,
minLength: 2,
select: function( event, ui) {
alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.value) : "Nothing selected, input was " + this.value);
$("input[id$='FormControl0_V1_I1_T27']").focus();
$("input[id$='FormControl0_V1_I1_T26']").val(ui.item.label);
$("input[id$='FormControl0_V1_I1_T27']").val(ui.item.value);
event.preventDefault();
return false;
},
focus: function(event, ui){
event.preventDefault();
$("input[id$='FormControl0_V1_I1_T26']").val(ui.item.label);
return false;
}
});function getCompany(){
var company = [];
$().SPServices({
operation: "GetListItems",
listName: "company",
CAMLViewFields: "",
CAMLQuery:"<Query><Where><Eq><FieldRef Name='Inactive'/><Value Type='Boolean'>0</Value></Eq></Where></Query>",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
company.push({label:$(this).attr("ows_Title"),value:$(this).attr("ows_ID")});
});
}
});
$("input[id$='FormControl0_V1_I1_T28']").autocomplete({
source: company,
minLength: 2,
select: function( event, ui) {
alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.value) : "Nothing selected, input was " + this.value);
$("input[id$='FormControl0_V1_I1_T29']").focus();
$("input[id$='FormControl0_V1_I1_T28']").val(ui.item.label);
$("input[id$='FormControl0_V1_I1_T29']").val(ui.item.value);
event.preventDefault();
return false;
},
focus: function(event, ui){$("input[id$='FormControl0_V1_I1_T28']").val(ui.item.label);
event.preventDefault();
return false;
}
});}
in the function getEmployee() and getCompany() i am using autocomplete for the textbxox, for the code windows.setTimeout(getData, 1000), my form gets very slower for every 1 sec it is getting postback , is there anyother solution for postback to make my form speed