1

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

4
  • what do you need to do with the fb_marketing.php page ? that's the question Commented Jan 24, 2013 at 22:55
  • what should be the result of the "call"? Commented Jan 24, 2013 at 22:58
  • The fb_marketing.php page just needs to be loaded, just like browsing to it via a browser. Commented 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 site Commented Jan 24, 2013 at 23:17

2 Answers 2

1

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'.

Sign up to request clarification or add additional context in comments.

1 Comment

You should probably mention that this requires jQuery.
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.