2014-02-25 90 views
0

我在使用$.getJSON因爲我總是得到錯誤中遇到的問題「Request format is unrecognized for URL unexpectedly ending in '/GetBranches'無法識別的網址.getJSON

這裏是我的代碼:

$.getJSON('testWS.asmx/GetBranches', function (data, status, xhr) { 
         console.log(data); 
        }); 

下面是web service

代碼
[WebMethod] 
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] 
public List<BranchesModel> GetBranches() 
{ 
    return BranchesBLL.Instance.GetBranches(); 
} 

我的網址有什麼問題?我怎樣才能解決這個問題,以便我可以使用$ .getJSON函數?

+0

試着用小的情況下數據類型: 'JSON' – Miller

+0

一個是'GET'另一個是'POST' – Deadlock

回答

0

這似乎是你缺少以下線在你的web配置.. 因爲默認情況下GET & POST是禁用的ASP.NET 2.0及以上

所以這些行添加到您的web.config和嘗試...

<configuration> 
    <system.web> 
    <webServices> 
     <protocols> 
      <add name="HttpGet"/> 
      <add name="HttpPost"/> 
     </protocols> 
    </webServices> 
    </system.web> 
</configuration> 

欲瞭解更多信息.. http://aspadvice.com/blogs/ssmith/archive/2007/09/04/FIX-Request-format-is-unrecognized-for-URL-unexpectedly-ending-in.aspx