Javascript AJAX URL字符串在变量之间添加空格

Javascript AJAX URL字符串在变量之间添加空格,javascript,ajax,Javascript,Ajax,我试图在ajax调用中使用“GET”,但url在参数中添加了空格 这是我的职责 function getLocation(id,clientid){ var formData ={ 'locationid' : id, 'clientbrandid' : clientid } var ajaxResponse = $.a

我试图在ajax调用中使用“GET”,但url在参数中添加了空格

这是我的职责

    function getLocation(id,clientid){

        var formData ={
                'locationid'            :   id,
                'clientbrandid'         :   clientid
            }

        var ajaxResponse = $.ajax({
                type : 'GET', // define the type of HTTP verb we want to use (GET for our form)
                url  : '/../admin/miscellaneous/components/global.cfc?wsdl&method=locationData', // the url where we want to GET
                data : JSON.stringify( formData ),
                contentType  : 'application/json',
                error  : function(data,status,error){
                        console.log(data+': '+status+': '+error);
                    },
                success :  function clientData(pair){
                        $.each(pair,function( intI, strWord ){
                    $("input[id=editlocationName]").val(strWord.locationname);
                    });
                    }   
            }).done(function(apiResponse) {
                    $('#response').append(apiResponse);
            });
}
这是正常工作,除了URL看起来像这样

http://somesite.com/admin/global.cfc?wsdl&method=locationData&{%22locationid%22:%222008013110482896439177%22,%22clientbrandid%22:%2235%22}
而不是

http://somesite.com/admin/global.cfc?wsdl&method=locationData&locationid=2896439177&clientbrandid=35

有人看到我的ajax调用有问题吗?

您正在将表单数据转换为JSON,而不是URL编码

jQuery内置了URL编码数据的例程,如果将对象而不是字符串传递给它,它将使用这些例程

改为:

data        : formData,

知道了。谢谢你的快速回复。