JQuery ajax function calling javascript
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 sample data
...
MyScript.js has the following
function display (text,corner)
{
}
..
I have Myscript.js. In this case, I have a function called display(text,corner)
. I have to call this function after ajax.php is done.
How do I do this in jQuery for the above code?
Is it possible to decide the order of execution after ajax.php and make a call for display(text,corner)
?
0
source to share
1 answer
You have to call the function display
in the Ajax request callback function like:
$.ajax({
type:'POST',
url: 'ajax.php',
success: function(data){
display(data, /* your other parameter, corner */); //Invoking your data function
}
});
In the above case data
, this is the answer fromajax.php
+1
source to share