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
-
what do you need to do with the fb_marketing.php page ? that's the questionmpm– mpm2013年01月24日 22:55:29 +00:00Commented Jan 24, 2013 at 22:55
-
what should be the result of the "call"?raidenace– raidenace2013年01月24日 22:58:14 +00:00Commented Jan 24, 2013 at 22:58
-
The fb_marketing.php page just needs to be loaded, just like browsing to it via a browser.user2002197– user20021972013年01月24日 23:03:37 +00:00Commented Jan 24, 2013 at 23:03
-
please read the FAQ of this site: a question is expected to show what you've tried, we should see that you've done your homework (as in: take a look what google has to say about AJAX), and the actual question should NOT be "write code for me", which you do seem to be asking here. SO is no free code generator, but a Q&A siteElias Van Ootegem– Elias Van Ootegem2013年01月24日 23:17:16 +00:00Commented Jan 24, 2013 at 23:17
2 Answers 2
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'.
1 Comment
jQuery.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.
Comments
Explore related questions
See similar questions with these tags.