URL checks friendly and ajax

Asked

Viewed 109 times

0

I am with the following problem, I made a URL friendly, but it is giving "conflict" when I use ajax in my Forms, when I click on Ubmit, it duplicates my site, my checks are like this

if(isset($_GET['url'])){

   $url=$_GET['url'];

   $sepURL=explode('/',$url);

}

$diretorio="paginas";

if(empty($sepURL)){

   include_once("$diretorio/home.php");

}elseif(isset($sepURL[0]) && $sepURL[0] == 'classificados' || isset($sepURL[0]) && $sepURL[0] == 'noticias'){

   include_once("$diretorio/class.php");

}elseif(isset($sepURL[0]) && $sepURL[0] == 'contato'){

   include_once("$diretorio/contato.php");

}

with this check, he is duplicating the site when I press some Ubmit that uses ajax on the site, someone knows how to solve?

1 answer

0

if the url parameter is not specified it will always fall into the home, have you ever thought to add a null condition ? in case a url is specified in this field and it is not preset you check if there is a file with that name ? so you mount specific callbacks for your ajax routes..

just add at the end something like this condition

elseif(file_exists($diretorio.$sepURL[0])){

   include_once($diretorio.$sepURL[0]);

}
  • would have a function to URL only to get files that are inside the pages directory ? so I think it would be easier and simple

  • that’s not what you’re doing ? then just set the specific routes for the ajax requests, so each file would be respective the route

  • will not old url:"ajax/busca.php",

  • that is why you are putting the file in another directory not ?

  • yes, just not the conflict between my pages and ajax, even so he is duplicating the site, in my modal with ajax, instead of opening the content of it, open the entire site within it, understood?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.