【发布时间】:2015-03-02 00:01:17
【问题描述】:
我正在开发jquery mobile 应用程序并尝试在我的本地主机上调用ajax,当我尝试使用ajax 获取json 值时,它会给出这些错误jQuery.ajaxTransport.send jQuery.extend.ajax ..
我真的对这种情况感到困惑,我找不到任何解决方案。如果我在ajax 从我的脚本中获取json 值之前删除或替换斜杠,它工作正常,但我的json 中有很多url 值并且不想替换所有这些值。我必须了解为什么会这样。希望你能帮助我。
Json 值
[{"Video_URL":"http:\/\/localhost\/video-1-season-trailer\/","Subtitle_URL":"http:\/\/localhost\/wp-content\/uploads\/abc.srt","Video_Image":"http:\/\/localhost\/wp-content\/uploads\/small-icons\/aaa.jpg","post_title":"Video Season 1","post_id":13649,"post_view":"2359","engsub":"none"}]
Ajax
$.ajax({
type: "POST",
url: 'http://localhost/androidjsonvol/?kategorisezon='+get_Cat+'&sezon=true&callback=?',
dataType: "json", // or jsonp
success: function(cat_Response){
var myJsonString = JSON.stringify(cat_Response);
$.mobile.changePage('bolum.html', { data : myJsonString, reloadPage : true, changeHash : true });
}, error:function (xhr, ajaxOptions, thrownError){
//error log
}
});
php端
$series_infos[]= array(
'Video_URL'=>$video_url, /* e.g http://localhost/video-1-season-trailer/ */
'Subtitle_URL'=>$video_sub,
'Video_Image'=>$small_icon,
'post_title'=>$post_title,
'post_id'=>$post_id,
'post_view'=>$view_count,
'engsub'=>$engsub
);
//for json
echo json_encode($series_infos);
// for jsonp
//echo $_GET['callback']. '(' . json_encode($series_infos) . ');';
/* ajax cant get this encoded value because it includes slash
but somehow if i change the array values with any string
without slash e.g : "stringvaluesforarray" it works fine */
【问题讨论】:
-
实际的响应正文是什么?
-
抱歉,您的意思是错误响应文本吗?
-
如果您提到的“Json 值”是实际的响应正文,那么您的代码应该没有任何问题。
标签: jquery ajax json jquery-mobile