gpt4 book ai didi

带有许多参数的javascript ajax发送到php文件

转载 作者:行者123 更新时间:2023-11-30 16:34:59 26 4
gpt4 key购买 nike

在我的 HTML 文件中,末尾有以下代码:

<script type="text/javascript">
function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
{
$.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
// alert("Data: " + data + "\nStatus: " + status);
alert(response);
});
}
</script>

但是当我加载 HTML 页面时出现错误:

XML Parsing Error: not well-formed Location: http://localhost/ajaxChat/ Line Number 626, Column 55: $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){ -------------------------------------------------------------^

如果我只使用一个参数,HTML 页面就会正确加载:

<script type="text/javascript">
function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
{
$.get("_vote/vote_ajax.php?userID="+userID, function(response){
// alert("Data: " + data + "\nStatus: " + status);
alert(response);
});
}
</script>

最佳答案

您的页面正在通过 XML 解析器运行,因此看起来您需要添加 CDATA block

<script type="text/javascript">
/* <![CDATA[ */
function voteUp(userID,userName,channelID,messageID,voteUp,voteDown) {
$.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
// alert("Data: " + data + "\nStatus: " + status);
alert(response);
});
}
/* ]]> */
</script>

关于带有许多参数的javascript ajax发送到php文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32828318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com