Answer the question
In order to leave comments, you need to log in
CNC and AJAX reloading elements with new selects from database?
Hello. There is an index.php handler, in which certain pages are inserted depending on what came running on $_GET['route'], and accordingly the page is reloaded and completely discards the information from the database.
I tried to implement it through ajax and ran into a data connection problem - every time I go to another page, I get a newly generated page in response (starting with the html tag) and, of course, the information does not get into the right div, because the div itself is in the same response.
How to make sure that we do not get the whole page, but only what is written in another php file that we need?
$('a.target_link').click(function() {
if ( this.href != location.href ) {
if( typeof window.history.pushState != undefined ) {
history.pushState( null, null, this.href );
}
$.ajax({
method : 'get',
url : this.href,
success : function( response ){
$('#content1').html( response );
console.log(response + 'gg')
}
});
}
return false;
});
switch($route[0])
{
case 'long':
if($route[1]!='')
include("long.php");
else
include("main.php");
break;
case 'contact':
include("contact.php");
break;
case 'about':
include("about.php");
break;
}
Answer the question
In order to leave comments, you need to log in
as I understand it, index.php is unloaded from you, to a heap with connected files, i.e. all in all.
I understand you have the DirectoryIndex /index.php directive right?
if yes, then it will be so - everything will be unloaded together. make available via the GET method in htaccess available urls for requests specifically to the files that you want to separately connect, in order to upload separately what is in files in other / current directory.
If you invent checks separately, it’s easier to drop into a separate folder what you want to connect
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question