如何将值从这样的链接传递到函数<a href="search=sony&offset=20&lang=en" class="more_info">Read More</a>
此链接不是静态的,值根据搜索词和页码而变化。使用jquery .ajax和hrefs
当用户点击此链接时,它会将这3个值发送到demo_search.php。结果以html形式返回。只刷新页面上的div。
我不知道如何获得这些值的函数中的数据部分。你能帮我解决这个问题吗?
$(function() {
$(".more_info").click(function() {
// ajax call
$.ajax({
type: "GET",
url: "demo_search.php",
data: Need help in getting those values from the href here,
beforeSend: function(html) {
$(".imgProgress").html(imgLoad);
},
success: function(page_data){
$("#results").empty();
$("#results").append(page_data);
$(".imgProgress").empty();
},
});
}
return false;
});
});
您应该可以这样做:'data:this.href'因为您的href包含可以直接放入数据选项的数据。 – 2012-07-23 14:56:56
可能的重复:http://stackoverflow.com/questions/2090551/parse-query-string-in-javascript – DevlshOne 2012-07-23 15:01:07