Reputation: 213
Am trying to load an external file to a div using this function
$(document).ready(function(){
$("#postdiv").load('posts.php');
});
This is working alright.
The problem is, I need to pass parameters/variables to posts.php from the caller page and use them to do some filtering.
How can i do this ?
Upvotes: 1
Views: 2826
Reputation: 11731
you can make an ajax call
$.ajax({
url: "posts.php",
data: data,
type: "post",
success: function(data){
$('#postdiv').html(data);
}
});
or you want to go for load then try below code
$( "#postdiv" ).load( "posts.php", { "test[]": [ "test1", "test2" ] } );
Upvotes: 0
Reputation: 11693
Use ajax
ajax is better option,best practice.
var value = "value of the data here";
$.ajax({
url: "posts.php",
data: "key="+value,
type: "post",
success: function(data){
$('#postdiv').html(data);
}
});
Upvotes: 1