正确写法:
$.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'); } }); 原因:接口带有
});