Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript API调用中的标点编码_Javascript_Jquery_Api - Fatal编程技术网

Javascript API调用中的标点编码

Javascript API调用中的标点编码,javascript,jquery,api,Javascript,Jquery,Api,我正在用JavaScript请求一个房地产API。我发送了一个街道地址,它会将有关房产的信息发送给我。它适用于大多数地址。但是,对于地址中有句点的地址(the street=U.s.395)来说,它不起作用,我想知道这个标点符号是否会使它失效,如果是的话,它是如何正确编码的 // grab address from html function getAddress() { address = $('.js-pma-address').val(); address = $.trim

我正在用JavaScript请求一个房地产API。我发送了一个街道地址,它会将有关房产的信息发送给我。它适用于大多数地址。但是,对于地址中有句点的地址(the street=U.s.395)来说,它不起作用,我想知道这个标点符号是否会使它失效,如果是的话,它是如何正确编码的

// grab address from html
function getAddress() {
    address = $('.js-pma-address').val();
    address = $.trim(address);
    ...
    data(address, locale);
}


// compile data for API query
function data(address, locale) {
    dataObj.Key = ...;
    dataObj.Address = address;
    dataObj.LastLine = locale.toString();
    ...
    compileRequest(dataObj);
}

// create url for API request
function compileRequest(dataObj) {
    var request = 'http://rc.api.sitexdata.com/sitexapi/sitexapi.asmx/AddressSearch?';
    request += $.param(dataObj);
    runQueries(request);
}

// run api query 
function runQueries(request) {
    $.ajax({
    url: 'lp/proxy.php',
    data: {requrl: request + '&reportType=187'},
    dataType: 'xml'
    })

尝试使用
encodeURIComponent()
。。。如果标点符号是罪魁祸首,那就应该纠正它

// compile data for API query
function data(address, locale) {
    dataObj.Key = ...;
    dataObj.Address = encodeURIComponent(address);  // <-- Right here
    dataObj.LastLine = locale.toString();
    ...
    compileRequest(dataObj);
}
//为API查询编译数据
函数数据(地址、区域设置){
dataObj.Key=。。。;

dataObj.Address=encodeURIComponent(Address);//尝试使用
encodeURIComponent()
…如果标点符号是罪魁祸首,那么应该纠正它

// compile data for API query
function data(address, locale) {
    dataObj.Key = ...;
    dataObj.Address = encodeURIComponent(address);  // <-- Right here
    dataObj.LastLine = locale.toString();
    ...
    compileRequest(dataObj);
}
//为API查询编译数据
函数数据(地址、区域设置){
dataObj.Key=。。。;

dataObj.Address=encodeURIComponent(Address);//尝试使用
encodeURIComponent()
…如果标点符号是罪魁祸首,那么应该纠正它

// compile data for API query
function data(address, locale) {
    dataObj.Key = ...;
    dataObj.Address = encodeURIComponent(address);  // <-- Right here
    dataObj.LastLine = locale.toString();
    ...
    compileRequest(dataObj);
}
//为API查询编译数据
函数数据(地址、区域设置){
dataObj.Key=。。。;

dataObj.Address=encodeURIComponent(Address);//尝试使用
encodeURIComponent()
…如果标点符号是罪魁祸首,那么应该纠正它

// compile data for API query
function data(address, locale) {
    dataObj.Key = ...;
    dataObj.Address = encodeURIComponent(address);  // <-- Right here
    dataObj.LastLine = locale.toString();
    ...
    compileRequest(dataObj);
}
//为API查询编译数据
函数数据(地址、区域设置){
dataObj.Key=。。。;
dataObj.Address=encodeURIComponent(地址)//