我对DOM以下jQuery函数准备:jQuery的/ Ajax的成功方法实现
$.ajax({
url : '/weather/',
type: 'GET',
//dataType : "json",
success : function(data) {
alert("success");
var jsondata = Object.keys(data);
alert(jsondata);
location = "testing";
alert(data.weather);
weather = data.weather;
$("location").text(location);
}
}).setTimeout(executeQuery, 500);
Ajax调用返回里面我是用改变我的html值适当JSON。但是,执行此行时,
$("location").text(location);
页面被重定向到一个url,该url附加上面一行中'location'的值。我在别处使用了这些行,而没有使用成功函数调用。
有人可以帮我做我应该做的事,以防止发生这种重定向吗?
jQuery选择器将找到一个DOM节点。但是,在这种情况下,它将转到document.location属性,该属性不正确。选择器可能缺少一个id(“#”)或class(“。”)标识符。 http://api.jquery.com/category/selectors/ – Askanison4