/ / अजीब अतुल्यकालिक जावास्क्रिप्ट और WebMethod व्यवहार - जावास्क्रिप्ट, asp.net, अतुल्यकालिक, webmethod, pagemethods

अजीब अतुल्यकालिक जावास्क्रिप्ट और WebMethod व्यवहार - जावास्क्रिप्ट, asp.net, अतुल्यकालिक, webmethod, pagemethods

मैं जावास्क्रिप्ट में एक पेजमेथोड कह रहा हूँ। इस तरह:

function DeleteBatchJS2()
{$find("mdlPassword").hide();
var pswd = $("#txtPassword").val();
var userInfo = get_cookie("UserInfo");
PageMethods.AuthenticateAndDelete(
userInfo,
pswd,
onSuccess(),
onError1());
}

function onSuccess(result)
{alert(result);}

function onError1(result)
{alert(result);}

अब यहाँ अजीब हिस्सा है: किसी को लगता है कि पेजमेथोड को कॉल करने पर एक (1) को चलाने पर अलर्ट मिलेगा। या तो onSuccess फ़ंक्शन या onError1 फ़ंक्शन। लेकिन - मुझे दो अलर्ट मिलते हैं, दोनों "अनडिफ़ाइंड" कहते हैं।

तथ्य की बात के रूप में, जब मैं एक विराम बिंदु में डाल दियाVB कोड-पीछे (फ़ंक्शन में कोड की 3rd या 4th लाइन की तरह), मुझे अपने कोड में पीछे जाने से पहले BOTH अलर्ट बॉक्स मिलेंगे। दो अलर्ट, और फिर मेरा कोड टूट गया।

त्रि - आयामी यह बेमतलब का लगता है। क्या मुझे कुछ याद आ रहा है?

धन्यवाद,

जेसन।

अनुलेख - यहाँ WebMethod फ़ंक्शन के लिए स्रोत है। कृपया ध्यान दें कि यह WCF कॉल करता है।

<WebMethod()> _
Public Shared Function AuthenticateAndDelete(ByVal UserInfo As String, ByVal Password As String) As Boolean
Dim Client As New LetterWriterClient
Dim bo As New BatchOperations
Dim UserNumber As String
Dim UserName As String


"Extract the user name and number from the user info cookie string
UserName = GetValueFromVBCookie("UserName", UserInfo)
UserNumber = GetValueFromVBCookie("UserNumber", UserInfo)

"Now validate the user
If bo.ValidateActiveDirectoryLogin("Backoffice", UserName, Password) Then
AuthenticateAndDelete = Client.Delete_dat_BatchSQL(UserNumber)
Client.Close()
Else
AuthenticateAndDelete = False
End If

End Function

उत्तर:

जवाब के लिए 0 № 1

होना चाहिए:

PageMethods.AuthenticateAndDelete(
userInfo,
pswd,
onSuccess,
onError1);
}

उत्तर № 2 के लिए 1

अपने हैंडलर फ़ंक्शंस के रिटर्न वैल्यू को पास करने के बजाय, onSuccess () और onError1 (), फ़ंक्शंस स्वयं पास करें, onSuccess और onError1।


जवाब के लिए 0 № 3

इस सत्रस्टैट के साथ एक स्टेटनेटवर्क टाइमआउट टैग शामिल है।

<sessionState timeout="540" stateNetworkTimeout="5"></sessionState>

मेरे पास एक स्टेटनेटवर्क टाइमआउट नहीं है, निश्चित रूप से यह हर बार बमबारी करता है।

धन्यवाद श्रीमान!