0
我正在通過JavaScript向房地產API發出請求。我發送了一個街道地址,併發送給我關於該地產的信息。它適用於大多數地址。然而,它並不適用於地址中有地址的地址(該街=美國395),我想知道該標點符號是否會將其丟棄,如果是,它如何正確編碼。在API調用中編碼標點符號
// 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'
})