我希望用户能够将URL地址的一部分更改为其邮政编码。我有一个文本框和按钮,我希望将提交值的URL。
的jQuery:
jQuery(document).ready(function($) {
$.ajax({
url : "http://SomeAddress.com/" + PostCode + ".json",
dataType : "jsonp",
success : function(parsed_json) {
HTML:
Set This Post Code
的jQuery:
$("#SetPostCode").click(function() {
var PostCode = document.getElementById("GetPostCode").value;
$("#GetPostCode").val(" ");
return false;
});
据我所知,线
$.ajax({
url : "http://api.wunderground.com/api/2508132ae0c7601a/geolookup/conditions/q/UK/" + PostCode + ".json",
不会这样工作,但我不知道还有什么要做。有人能告诉我我需要做什么才能使其工作?
+2
如果这是你的排序 –
+2
为什么那就没办法了,如果邮编是不是全球性的..唯一的原因,不要在点击处理程序中的'var PostCode'行之后执行'$ .ajax'? –
+1
+1 @CarlSaldanha因此,您可以在点击函数中设置PostCode变量,因此无法从其他位置访问它。 –