0

How to use the PHP "include" function after a javascript code, cause when the animation starts it stops because it has to load the php included page. So I want to "include" the page after the animation is ready. How can I do that?


This is my animation:
$( ".izkustvo" ).click(function(){ $('#izkus').show(); $(".izkus").switchClass("izkuz", "tvo", 1500, 'easeInExpo').switchClass( "tvo", "zavur6en", 3000, 'easeOutQuart'); });
here is the button and the PHP codes in my 'index' page:
<li><a href="index.php?page=izkustvo" class="izkustvo" >izkustvo</a></li>
and
if($_GET['page'] == "izkustvo"){ include("pages/karieri.php");

1
  • 4
    you're confusing / mixing front and backend development here Commented Jan 9, 2012 at 12:24

3 Answers 3

2

Can you be more specific in your question? What animation exactly?

As @Hosh Sadiq noted, you could try using AJAX (http://api.jquery.com/jQuery.ajax/).

One way to get PHP in after a page already has loaded (without reloading it again):

$.ajax({
    url: 'target/file.php',
    success: function(response) {
        $("#target-div").html(response);
    }
}); 

this snippet could be called when you "animation" is complete.. If this does not answer your question, I suggest you be a little more clear in what you're trying to accomplish here :)

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

1 Comment

@Muthu Krishnan I'VE DONE IT! And as i said before GOD BLESS US! :) :) :)
1

Because PHP is server side, and JavaScript is client side, this wouldn't be possible. You could try using AJAX maybe?

3 Comments

I know what AJAX is, but i do not know exactly what do you mean.
What I mean is PHP is always executed before any JavaScript due to PHP being run before JavaScript. Based on what you are trying to achieve, AJAX will be the only way, see Chrules answer, he's put up an easy and quick way of using AJAX to do this. Also, jQuery animate has an onsuccess callback function which is only executed after the animation is completed (you can obviously make an AJAX request in this callback function).
I'VE DONE IT! And as i said before GOD BLESS US ALL! :) :) :)
0

You can easily achieve this by jquery.load();

1 Comment

I'VE DONE IT! And as i said before GOD BLESS US ALL! :) :) :)

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.