Domanda

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.

È stato utile?

Soluzione

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

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

Altri suggerimenti

You can use absolute paths for your url like

url : "/ezleague/submit.php"

Do not use the server name, so your script is portable to other domains.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top