利用jsonp的url值传参,当url传的参是一个带参数的网址时,会出现错误,
想问下如何解决?
具体说明如下
var url='https://mp.weixin.qq.com/s/wVur--8_KJmbUQb8FPvqlw';
$.ajax({
type: "get",
dataType:"jsonp",
url: './php/getarticle_wx.php?url'+url,
jsonp: "jsoncallback",
async:false,
success: function (res) {
console.log(JSON.stringify(res));
$("#a").html(res.title);
}
});
后台
<?php
header('content-type: application/json; charset = utf-8');
$arr=file_get_contents($_GET['url']);
当这种情况,即我要传递的url值没有?和&f符号时正常,当有?和&符号就
保存
var url="https://mp.weixin.qq.com/s?src=11×tamp=1561732560&ver=1696&signature=Pbbe2WJ952LfXT1jlBSYqZ7fUMTnyCWBR1uk39vRxdiojC-9OXtPpdCG3cbThGrg0*2p2I9aP9MhjF9v6npDmDWjzYQk3NWq5TuBDHs7WOQvzLy8Kg9ugEIkinq1OQDy&new=1";
当url为该值时就会报错,问下应该怎么解决