vote up 0 vote down star

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

flag

78% accept rate

1 Answer

vote up 1 vote down check

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

link|flag
Thanks Dreas Grech, Now Working Fine – venkatachalam Dec 25 '08 at 9:21

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.