jQuery ajax calling javascript function - Stack Overflow

I am using jQuery and Ajax.My MainFile has the following code:<html><head><script src=&q

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)?

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)?

Share Improve this question edited Jul 11, 2014 at 13:25 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Dec 25, 2008 at 9:07 venkatachalamvenkatachalam 102k31 gold badges74 silver badges77 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745113990a4612017.html

相关推荐

  • jQuery ajax calling javascript function - Stack Overflow

    I am using jQuery and Ajax.My MainFile has the following code:<html><head><script src=&q

    7小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信