I have a variable - x
in jquery, I am loading a php part in div
block and I need sent that variable to it.
So -
$(document).on('click','#link',function () {
var x=5;
$("#block").load("file.php");
});
In result I am still in the same page.I just need to have variable x
in it.
I think about to use GET method or XMLHttpRequest but I don't want to another page, I just need to load a php part in block.
One solution is to send data as second argument:
$(document).on('click', '#link', function() {
$("#block").load("file.php", {
x: 5
}, function(res) {
//your callback
});
});
References
.load()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With