Reputation: 101
Can I please have some help to call a PHP file via Javascript when an HTML page has successfully loaded.
Here is my code:
<script class="code" type="text/javascript">
$(document).ready(function(){
//Call fb_marketing.php
});
</script>
The name of the PHP file is 'fb_marketing.php'. Can I please have some help to get this code working?
Thanks in advance
Upvotes: 1
Views: 7119
Reputation: 467
You can call this file in AJAX as Musa said. Here is a sample code that tells what I mean:
<script class="code" type="text/javascript">
$(document).ready(function(){
$('#div').load('fb_marketing.php');
});
</script>
In this code, #div calls the place that you want to put your PHP file. You can use this
instead of '#div'
.
Upvotes: 1
Reputation: 2032
you have to watch the outcome you expect from php, one way to do is use JSON notation for a quick reading of the data. To this we must put the corresponding header in our php file which will return the result.
Upvotes: 0