Wednesday, March 21, 2012

Web Service Call executes 2 times !

Hello

When I make a call to an asynchronous web service the call is executes 2 times ! Except when I display an alert message before treating the result from the server, it only executes 1 time.

Here is my code on the client side:

functiononComplete(result)
{
var count=result.rows.length;
varcity=$get("<%= txtCity.ClientID %>");

if (count== 1)
city.value=result.rows[0].upName; (upName is the name of the city in the database)
else
{

alert('stop'); ---> WHEN I ADD THE ALERT MESSAGE HERE THE WEB SERVICE IS EXECUTED ONCE
----> WHEN I OMIT THE ALERT MESSAGE IT IS EXECUTES TWICE !

varsel=document.createElement('select');
sel.setAttribute('id', 'ddlCity');
sel.options[0]=newOption('<-- Select your city-->');

for (vari=0;i<result.rows.length;i++)
sel.options[i+1]=newOption(result.rows[i].upName);

document.getElementById('divCity').appendChild(sel);
}
}

Already found where my problem was.

When using my keyboard of my notebook, I have to use the SHIFT key to enter the numbers, and there are always 2 events triggered.

1) releasing the last digit itself to search
2) releasing the SHIFT key

So... problem solved :-)

No comments:

Post a Comment