Reputation: 1
I'm new in programing websites so forgive my lack of knowledge... I'd like to load some content from database without reloading page. So using jquery I can load php file which conects with database
$("body").on("click",".editpages", function(){
$('#pagesedit').load('/templates/admin/pages.php #edit');
});
Problem is that I need to send one variable that I can use it in my php file. How can I do that?
Upvotes: 0
Views: 57
Reputation: 519
Id recommenced looking at PHP Get Varriables. First just pass the varriable to your php page.
$("body").on("click",".editpages", function(){
$('#pagesedit').load('/templates/admin/pages.php?YOUR_VARIABLE_NAME');
});
<?php
if isset(htmlspecialchars($_GET["name"])) {
// DO WHATEVER IN PHP
}
?>
Upvotes: 1
Reputation: 212
Use Jquery Ajax
$("body").on("click",".editpages", function(){
$.post( "templates/admin/pages.php", { yourVariable: "John" })
.done(function( data ) {
alert( "Data Loaded: " + data );
});
});
Upvotes: 1