0

I am using jQuery and Ajax.

My MainFile has the following code:

<html>
    <head>
        <script src="Myscript.js">
        </script>
        <script type="text/javascript">
            $(document).ready(function(){
                $.ajax({
                    type: 'POST',
                    url: 'ajax.php',
                    success: function(data){
                        $("#response").html(data);
                    }
                });
            });
        </script>

    <body>
        <div id="response">
        </div>
    </body>
</html>

My ajax.php get the sample data

...
MyScript.js has the following

function display (text,corner)
{

}
..

I have Myscript.js. In this, I have a function called display(text,corner). I have to call this function after executing ajax.php.

How do I do it in jQuery for the above code?

Is it possible to decide the order of execution after ajax.php and make call for display(text,corner)?

1 Answer 1

1

You should invoke the display function in the callback function of the Ajax Request, like such:

$.ajax({
    type:'POST',
    url: 'ajax.php',
    success: function(data){
        display(data, /* your other parameter, corner */); //Invoking your data function
    } 
});       

In the above case, data is the response that is received from ajax.php

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

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.