下面附上我写的代码
前提,在点击左边菜单栏里面的任意一个图标时,这个图片有连接地址,在点击图片的同时,跳转到另一个页面出现一个图片弹层说明层,下面是根据这个图片返回的一个地址,然后我用post来请求它的数据,但是这个post频繁的返回404错误,请各位大侠帮帮忙!
$('.mox_medal li').bind('click',function(){
var id = $(this).attr('id').slice(1);
$.post('/apps/medal/api.php?do=Get&mid='+ id +'&format=json',function(data){
$('.explain_left p').eq(0).html('<img width="110" height="110" src='+a[id].img2+'>');
$('.explain_right p').eq(0).html(a[id].title);
$('.explain_right p').eq(1).html(a[id].desc);
$('.explain_right p').eq(2).html('任务名称:<a class="blue" href="/apps/task">'+a[id].title+'</a>');
if(data.code ==200){
$('#medal_dialog').show();
$('#medal_dialog').dialog();
$('.dialog_content').css("top","300px");
$('.dialog_content').css("margin-left","-110px");
}
})
return false;
})
jquery 使用post进行提交,但返回的是404错误,那一定是找不到资源,基本上是路径不对。 其实开发ajax应用,我建议你装个firefox的firebug,或者是用chrome自带的调试工具。
jquery中使用post方法提交数据时,返回404错误的解决方法:
1、jquery代码
2、解决办法;
在.htaccess中,修改apache的mod_rewrite,内容如下:
是偶尔出错奥,不是一直出错,!
追答可以肯定的是,如果是404错误,那一定是找不到资源,基本上是路径不对。
其实开发ajax应用,我建议你装个firefox的firebug,或者是用chrome自带的调试工具,一目了然。