2013-04-26 58 views
0

我正在使用wcf服務來驗證用戶。該服務根據用戶名/密碼是否有效返回true或false。如何將返回的值傳遞給javascript函數以決定驗證是否失敗或通過。使用wcf進行服務器端驗證的javascript函數

 function AuthenticateUser(email, password, onSuccess, onFailed) 
    { 

      var person = { "Email": $("#Email").val(), "Password": $("#Password").val() }; 
      req = $.ajax({ 
       type: "POST", 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       data: JSON.stringify(person), 
       url: wsUrl + "/AuthenticateUser", 
       success: function() 
        { 
        req = null; 
        onSuccess(); 
       }, 
       error: function (jqXHR, textStatus, errorThrown) { 
        if (textStatus != 'abort') 
         onFailed(errorThrown); 

回答

0

IMO其濫竽充數作爲參數添加您的預期的結果你的onSuccess方法,如:

function onSuccess(result) 
: 
... 
} 

this post例如。

相關問題