我正尝试在我的站点中实现Postcode Anywhere。因此,如果他们在事件邮政编码字段中输入邮政编码,系统将显示与该邮政编码相关的地址,用户将选择相关地址,然后地址详细信息将填充事件地址字段的其余部分。我在页面中使用以下代码:
function CapturePlus_Interactive_Find_v2_10Begin(Key, SearchTerm, LastId, SearchFor, Country, LanguagePreference, MaxSuggestions, MaxResults) {
var script = document.createElement("script"),
head = document.getElementsByTagName("head")[0],
url = "http://services.postcodeanywhere.co.uk/CapturePlus/Interactive/Find/v2.10/json3.ws?";
// Build the query string
url += "&Key=" + encodeURIComponent(Key);
url += "&SearchTerm=" + encodeURIComponent(SearchTerm);
url += "&LastId=" + encodeURIComponent(LastId);
url += "&SearchFor=" + encodeURIComponent(SearchFor);
url += "&Country=" + encodeURIComponent(Country);
url += "&LanguagePreference=" + encodeURIComponent(LanguagePreference);
url += "&MaxSuggestions=" + encodeURIComponent(MaxSuggestions);
url += "&MaxResults=" + encodeURIComponent(MaxResults);
url += "&callback=CapturePlus_Interactive_Find_v2_10End";
script.src = url;
// Make the request
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
script.onload = script.onreadystatechange = null;
if (head && script.parentNode)
head.removeChild(script);
}
}
head.insertBefore(script, head.firstChild);
}
function CapturePlus_Interactive_Find_v2_10End(response) {
// Test for an error
if (response.Items.length == 1 && typeof(response.Items[0].Error) != "undefined") {
// Show the error message
alert(response.Items[0].Description);
}
else {
// Check if there were any items found
if (response.Items.length == 0)
alert("Sorry, there were no results");
else {
// PUT YOUR CODE HERE
//FYI: The output is an array of key value pairs (e.g. response.Items[0].Id), the keys being:
//Id
//Text
//Highlight
//Cursor
//Description
//Next
}
}
}
我不确定在代码的其他部分要写什么(我需要把实际的代码放在那里来Map值),有人能帮我吗?
1条答案
按热度按时间xfb7svmp1#
如果你在那里的网站上看,有一个工作的例子。2看看网页后面的代码
http://www.pcapredict.com/support/webservice/captureplus/interactive/find/2.1/
祝你好运