dojo将URL参数传递给AJAX

时间:2010-09-30 19:25:42

标签: ajax dojo

我想获取URL参数并传递给ajax函数,

    var queryParams = dojo.queryToObject(window.location.search.slice(1));
    var data = dojo.toJson(queryParams, true);
     console.log(data);
    getCategory( data );
...
function getCategory(input){


    dojo.xhrGet( {
            // The following URL must match that used to test the server.
            url: "http://js.localhost/dojo-release-1.5.0-src/json3.php",
            handleAs: "json",
            content: input,

在我的网址参数上,我传入

  ?

return_type =类别&安培; category_desc =业务2

当我查看firebug时,ajax请求变为....

  

吨0 =%7B&安培; 1 =%0A和2 = 09%和3 ......

但是数据调试是正确的,知道什么是错的吗?

  

{“return_type”:“category”,   “category_desc”:“Business2”}

1 个答案:

答案 0 :(得分:1)

刚刚发现它不需要dojo.toJson

var queryParams = dojo.queryToObject(window.location.search.slice(1));
getCategory(  queryParams );