我有两个文件:inventory.php它有一些JavaScript函数,一个名为(items),看起来像:
function items(page,cat,order,column)
{
alert('hiiiiii');//testing msg
var xhr = new getNewXmlHttpObj();
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
//alert(xhr.responseText);
document.getElementById('items').innerHTML=xhr.responseText;
}
}
var URL="ajax/inventory_items.php";
xhr.open("POST",URL,true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var info="page="+page+"&cat="+cat+"&order="+order+"&column="+column+"&dummy=" + new Date().getTime();
xhr.send(info);
}
另一个文件inventory_items.php返回要在项目div 中显示的 HTML 代码。inventory_items我有一个下一页的链接,如下所示:
echo "<a href='#' class='red' onclick='"items($next_page,$cat,$order,$column); return false; '">Next</a>";
问题出在 OnClick 上,它根本不调用 (items) 函数,同时更改为 onclick=''"alert('something');''"工程!
我想知道有什么问题,我在 Windows(在 win8 之前)上有相同的代码并且它运行良好,但现在我使用的是 Windows 8,它有什么区别吗?如何使点击工作?请帮忙
修复了它!问题是我必须在单引号中包含非数字变量,如下所示:
<a href='#' class='red' onclick='"items($next_page,$cat,'$order','$column'); return false; '">Next</a>