dongluan1743 2014-03-23 06:21
浏览 22
已采纳

ajax提交请求与漂亮的URL

i'm building my first "pretty url" web site, but when i attempt to run any of the AJAX Request functions, they are not being passed to the correct file (submit.php)

i have 1 file that holds all of the AJAX requests (http://mdloring.com/ezleague/submit.php):

function joinLeague(guild, league) {
    $.ajax({
         type: "POST",
         url: "submit.php",
         data: "form=joinLeague&guild=" + guild + "&league=" + league
       }).success(function( msg ) {
           $('.login_success').css("display", "");
              $(".login_success").fadeIn(1000, "linear");
              $('.login_success_text').fadeIn("slow");
              $('.login_success_text').html(msg);
              //setTimeout(function(){location.reload()},3000);
      });
}

on one of my "pretty url" pages (http://mdloring.com/ezleague/game/counter-strike), i have a button that triggers the above function, but the URL it attempts to pass the request to is: http://mdloring.com/ezleague/game/counter-strike/submit.php , instead of http://mdloring.com/ezleague/submit.php

i'm really lost on this one. help is greatly appreciated.

  • 写回答

2条回答 默认 最新

  • duanmo6937 2014-03-23 06:26
    关注

    Its due to the relative URL pattern. Try using absolute URL pattern

    url: "http://mdloring.com/ezleague/submit.php" in the AJAX call

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记