2013-02-07 21 views
0

我正在作爲asp.net應用程序工作。它認爲有這樣一個按鈕:ajax成功的方法不顯示數據在asp.net mvc

<input type="button" id="btnCall" title="Call" value="Call" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" /> 

和的document.ready,我有這樣的:

$("#btnCall").click(function() { 
    alert("here"); 
    $.ajax({ 
     type: "POST", 
     dataType: "text/json", 
     url: "/account/getGenericPassword", 
     success: function (data) {     
      alert("data" + data); 
      if (data == null || data == "") { 
       alert("Generic Password is empty. Please enter generic password"); 
      } 
      else { 
       //saveCallRecording(); 
      } 
     } 
    }); 
}); 

和方法是這樣的:

[Authorize] 
public JsonResult GetGenericPassword() { 
    using (IUserProfileManager profilemanager = new ManagerFactory().GetUserProfileManager())   { 
      UserProfile profile = profilemanager.GetProfile(CurrentUser.Id, CurrentAccount.Id); 
      return Json(profile.GenericPassword == null ? "" : profile.GenericPassword, JsonRequestBehavior.AllowGet); 
    } 
} 

但警報在成功是未顯示。請建議解決方案。

+0

任何錯誤消息? –

+2

使用瀏覽器中的開發工具設置斷點並觀看AJAX流量。它在什麼時候失敗?您的點擊處理程序受到了影響嗎服務器被擊中了嗎? – StriplingWarrior

+0

是的服務器端被擊中,但沒有任何東西在瀏覽器上顯示爲警報 – DotnetSparrow

回答

0

嘗試用這些

類型: '郵報',
網址:'@網址.Action(「actionname」,「controller」)',
datatype:「json」,
data:{},
成功:function(data){ }

相關問題