我正在抓取页面的 HTML 并尝试通过 jQuery 的 ajax() 函数将其作为字符串发送到 PHP Web 服务。当我在 PHP 端获取参数时,HTML 中的 URL(例如图像的 src 属性)中的 &s 被转换为&并且链接不起作用。例子:<img src="https://somesite.com/path/file.php?foo=bar&biz=buz&bat=bot">结果:<img src="https://somesite.com/path/file.php?foo=bar&biz=buz&bat=bot">
2 回答
慕田峪4524236
TA贡献1875条经验 获得超5个赞
在客户端对您的 html 进行编码:
var html = '<img src=" var encodedHtml = btoa(html);
将其发布到服务器并使用 php 将响应字符串解码为 html:
$html = base64_decode( $encoded_html );
添加回答
举报
0/150
提交
取消