jQuery的AJAX调用javascript函数 [英] jQuery ajax calling javascript function
本文介绍了jQuery的AJAX调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery和Ajax。
I am using jQuery and Ajax.
我MainFile具有以下code:
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>
我ajax.php获取样本数据。
My ajax.php get the sample data
...
MyScript.js has the following
function display (text,corner)
{
}
..
我有Myscript.js。在这方面,我有一个名为显示功能(文字,角)
。我必须在执行ajax.php后调用此函数。
I have Myscript.js. In this, I have a function called display(text,corner)
. I have to call this function after executing ajax.php.
我如何做jQuery的对于上述code?
How do I do it in jQuery for the above code?
是否有可能ajax.php后决定执行的顺序,并呼吁显示(文字,角)
?
Is it possible to decide the order of execution after ajax.php and make call for display(text,corner)
?
推荐答案
您应该调用显示
函数在Ajax请求的回调函数,像这样的:
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
}
});
在上述情况下,数据
是从 ajax.php
这篇关于jQuery的AJAX调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文