Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Windows.setTimeout() reducing my form speed

$
0
0
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);
      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

Viewing all articles
Browse latest Browse all 6517

Trending Articles