首页 > Web开发 > 详细

jsonp请求返回前面带有个null

时间:2021-04-18 11:18:47      阅读:37      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 正确写法:

$.ajax({
type: "get",
url: ‘<%=APP_URL_ZZGRID%>/zzgl/map/data/situation/getPlayRtspJsonp.json‘,
dataType: "jsonp",
jsonp: "jsoncallback",
data: {
monitorId: monitorId
},
success: function (data) {
if (data.rtspUrl != ‘‘ && data.rtspUrl != undefined ) {
var rtsp = data.rtspUrl.replace(/\?/g, ‘%3F‘).replace(/&/g, ‘%26‘).replace(/=/g, ‘%3D‘);
var url="<%=skyDomain%>/shequ/video/index.jhtml?streamAddr="+rtsp;
$(‘#monitor_1‘).html(‘<iframe src="‘+url+‘" allowfullscreen="true" allowtransparency="true" webkitallowfullscreen="true" width="100%" height="100%" scrolling="no"></iframe>‘);
} else {
$.messager.alert(‘错误‘,‘获取播放链接失败!‘,‘error‘);
}
},
error:function(data){
$.messager.alert(‘错误‘,‘获取rtsp异常!‘,‘error‘);
}
错误写法:
$.ajax({
type: "POST",
url: ‘<%=APP_URL_ZZGRID%>/zzgl/map/data/situation/getPlayRtspJsonp.json‘,
dataType: "jsonp",
data: {
monitorId: monitorId
},
success: function (data) {
if (data.rtspUrl != ‘‘ && data.rtspUrl != undefined ) {
var rtsp = data.rtspUrl.replace(/\?/g, ‘%3F‘).replace(/&/g, ‘%26‘).replace(/=/g, ‘%3D‘);
var url="<%=skyDomain%>/shequ/video/index.jhtml?streamAddr="+rtsp;
$(‘#monitor_1‘).html(‘<iframe src="‘+url+‘" allowfullscreen="true" allowtransparency="true" webkitallowfullscreen="true" width="100%" height="100%" scrolling="no"></iframe>‘);
} else {
$.messager.alert(‘错误‘,‘获取播放链接失败!‘,‘error‘);
}
},
error:function(data){
$.messager.alert(‘错误‘,‘获取rtsp异常!‘,‘error‘);
}
});
原因:接口带有

技术分享图片

 

 




});

jsonp请求返回前面带有个null

原文:https://www.cnblogs.com/xyyou/p/14672640.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!