I embedded a PHP file with JavaScript but the PHP didn't work. Here's what I did:
$.get("php/file.php");
In the PHP file:
<?php
echo "Testing PHP File"
?>
I would really appreciate it if someone answered me!
you should used $.get() like this
$.get('php/file.php', function(data) {
alert(data);//here is your "Testing PHP File" data
});
Make sure: this will work on any event like click or other (i suppose you know about server side and client side)
$('.class_name').click(function() {
$.get('php/file.php', function(data) {
alert(data);
});
});
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