【发布时间】:2016-01-10 08:05:47
【问题描述】:
下面的脚本发送一个对象而不是一个数字。我进入控制台:
获取 http://localhost:8080/new_prog_22/paginator.action?page=[object%20Object] 500(内部服务器错误)
我只需要发送hash 变量,它是一个数字,因为我的链接看起来像
<a class="idPage" href="#4">4</a>
当我按下链接时,我会在浏览器中收到警报通知An error occurred! ' + thrownError
我也不接受来自console.log("**** hash = "....的输出
脚本:
function paginFunc() {
$( function() {
$(window).on('hashchange', refreshByHash);
var hash = window.location.hash;
hash = hash.substring(1);
console.log("**** hash = " + hash + " ****");
refreshByHash( hash );
});
function refreshByHash( hash ) {
$.ajax({
url : 'paginator.action?page=' + hash, // action to be perform
type : 'GET', //type of posting the data
dataType : 'html',
async: true,
success : function(htmlData) {
$('#paginator').html(htmlData);
},
error : function(xhr, ajaxOptions, thrownError) {
alert('An error occurred! ' + thrownError);
},
});
}
}
这段代码有什么问题?
【问题讨论】:
标签: javascript jquery