views:

1825

answers:

1

Dear all, 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 have function called display(text,corner). I have to call this function after executing ajax.php.

How to do in JQuery for above code..any help?

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

+1  A: 

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

Andreas Grech
Thanks Dreas Grech, Now Working Fine
venkatachalam