2009-06-01 69 views
1

我設法設置了一個簡單的webmethod,我從jquery中調用並確信它返回...然後我在該方法上添加了參數,並將參數添加到jquery中,但它的錯誤與從jquery錯誤調用帶參數的asp.net webmethod

 Message":"Invalid JSON primitive: one.","StackTrace":" 

我在我的webmethod簽名是像這樣

[WebMethod] 
    public static string GetDate(string one, string two) 
    { 
     return "yes"; 
    } 

和我的jQuery是這樣的,我在做什麼錯?

   $.ajax({ 
       type: "POST", 
       url: "MyService.aspx/GetDate", 
       data: { one: "value", two: "value" }, 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: function(msg) { 
        alert(msg.d); 
       }, 
       error: function(msg) { 
       alert('error'); 
       } 

      }); 

回答

4

嘗試圍繞你的數據參數報價:

data: '{ one: "value", two: "value" }', 
+1

數據: 「{ '一': '值', '二': '值'}」 也將工作。 +1 – ichiban 2009-06-01 20:25:30

相關問題