2009-10-08 32 views
0

我可以調用我的ASP.Net頁面方法,如果我使用POST,但是如果我嘗試GET失敗,就可以調用。 任何想法爲什麼?使用GET調用PageMethod w/jQuery

var url = encodeURI(acx.opts.queryURL + "?t=" + acx.input.val()); 

    acx.requestExe = $.ajax({ type: "GET", 
     url: url , 
     //data: "{\"t\":\"" + acx.input.val() + "\"}",  //Data To Send If POST 
     contentType: "application/json",     //Of Request 
     dataType: "json",        //Return Type Expected 
     cache: true, 
     success: function(d) { showQueryResults(acx,d); }, 
     error: function(d) 
     { 
      var r = JSON.parse(d.responseText); 
      alert(r.Message); 
     } 
    }); 

回答

0

檢查你的web.config system.web -> httpHandler並確保你的處理程序允許GET動詞。

0

嘗試指定option.data

acx.requestExe = $.ajax({ 
    type:  "GET", 
    url:   encodeURI(acx.opts.queryURL), 
    data:  "{\"t\":\"" + acx.input.val() + "\"}", 
    contentType: "application/json",     
    dataType: "json",        
    cache:  true, 
    success:  function(d) { showQueryResults(acx,d); }, 
    error:  function(d) { 
     var r = JSON.parse(d.responseText); 
     alert(r.Message); 
    } 
}); 

不用手動建立在你的查詢字符串:

var url = encodeURI(acx.opts.queryURL + "?t=" + acx.input.val()); 
0

試圖通過data作爲對象來代替:

acx.requestExe = $.ajax({ 
    type: "GET", 
    url: acx.opts.queryURL, 
    data: { 
     t: acx.input.val() 
    }, 
    contentType: "application/json", 
    dataType: "json", 
    cache: true, 
    success: function(d) { 
     showQueryResults(acx,d); 
    }, 
    error: function(d) { 
     var r = JSON.parse(d.responseText); 
     alert(r.Message); 
    } 
});