以下代码获取 html,编码并将其发送到任何 php 文件。php 文件只包含“hello”字符串。但是当函数运行时,它可以获得所有 html,但不能发送字符串长的原因。因为您看不到 HELLO 警报。Ajax允许定义最长?我对吗?
function getlongdata(){
htmldatas=encodeURIComponent($('#divlongcontent').html());
alert(htmldatas);
$.ajax({
type: "GET",
url: "sayhello.php",
data: "longdatago="+htmldatas,
success: function(msg){
alert(msg);
}
});
}
<div id="divlongcontent">blablabla1000000000timesblaaaaaaa</div>