2011-07-13 6 views
0

私はJavaScriptでPageMethodを呼び出しています。このように:奇妙な非同期JavascriptとWebMethodの振る舞い

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);} 

ここでは奇妙な部分があります。実行中にPageMethodsを呼び出すと1つの警告が表示されると考えられます。 onSuccess関数またはonError1関数です。しかし、私は "Undefined"と言っている2つのアラートを得る。

実際には、VBコードビハインド(関数の3行目または4行目のコードのように)にブレークポイントを置くと、後ろのコードにステップインする前に警告ボックスが表示されます。 2つの警告が表示され、次にコードが破損します。

これは意味をなさない。私は何か不足していますか?

ありがとう、

Jason

P.S. - ここに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

は次のようになります。

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

括弧を削除しましたが、今はどちらのメッセージボックスも表示されません。 –

+1

タイムアウトになる可能性はありますか? – Mrchief

+0

もちろん十分でした。回答を投稿してインデックスに登録できるようにしますが、答えとしてあなたの名前を付けて投票します。ありがとう!!! –

1

代わりに、あなたのハンドラ関数の戻り値を渡すので、すなわちするonSuccess()とonError1()、機能そのもの、すなわちするonSuccessとonError1を渡します。

+0

早く試してみて、同じ結果が得られました –

+0

私はそれを真剣に疑っています。この変更がなければ機能する可能性はありません。 – James

0

てsessionStateに関与stateNetworkTimeoutタグがあります。このように:

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

私はstateNetworkTimeoutを持っていませんでした。毎回十分に爆撃されました。

ありがとうございました!