2012-11-12 104 views
0

我有一個代碼:什麼是AjaxAdapter和什麼是query()?

req = new AjaxAdapter; 
req.dataType = 'json'; 

return req.query('GET', url, request, function(responseServer, status, xhr) { 
     var json; 
     json = responseServer.data; 
     return response(json); 
    }, function(jqXHR, textStatus, errorThrown) { 
     var exception; 
     exception = jQuery.parseJSON(jqXHR.responseText); 
     return showError(exception); 
    }); 

而且我不明白。那麼query()函數是什麼?我無法在jQuery文檔中找到它。見我的例子中,這個函數有5個參數:

  • 得到
  • 網址
  • 要求
  • 函數返回數據(響應)
  • 功能是通話時的錯誤

請求是什麼?我在哪裏可以找到query()函數的文檔?

+3

這不是jQuery。 – Sampson

+0

我認爲問題是:什麼是AjaxAdapter?你能找到AjaxAdapter的定義嗎? –

+0

https://groups.google.com/forum/?fromgroups=#!topic/wireit/psZEjY3L3Go – jbabey

回答

0

這不是jQuery。至於query方法做什麼,看看它的簽名:

req.query('GET', url, request, function(responseServer, status, xhr) 

它需要的類型後,作爲第一個參數,URL作爲第二個,你的請求數據作爲第三,和一個回調函數,當請求完成。

您的回調函數將返回服務器的響應,一個指示響應類型的狀態碼以及用於發出請求的查詢方法的XHR對象。

0

query功能不存在的jQuery

您必須使用另一個庫

0

這不是jQuery的,但你可以嘗試

console.log(AjaxAdapter.query) 

看到的功能是什麼

0

使用jQuery $ .ajax代替

var request = $.ajax({ 
    url: "script.php", 
    type: "POST", 
    data: {id : menuId}, 
    dataType: "html" 
}); 

request.done(function(msg) { 
    $("#log").html(msg); 
}); 

request.fail(function(jqXHR, textStatus) { 
    alert("Request failed: " + textStatus); 
}); 
+0

雖然可能是一個有效的*替代*,它並不回答問題本身。 –