我如何使用Ajax使用jQuery在Perl? [英] How do I use Ajax with jQuery in Perl?
问题描述
如果我调用此函数直接它工作正常,但如果我使用AJAX调用从JavaScript调用它不会正常工作。
If I call this function directly it works fine, yet if I call it from Javascript using an ajax call it wont work correctly.
我发现这样做的原因,那是因为我是用$(文件)。就绪(函数..)我应该在哪里调用的函数后直接AJAX返回结果。
I found out the reason for this, it was cause I was using $(document).ready(function ..) where I should call the functions directly after the ajax returns the results.
推荐答案
如此混乱,你的Perl code只是HTML输出没有任何标题(如内容类型)。您的JavaScript似乎没有使用jQuery,并没有任何提及ID的任何地方出现在你的榜样。
So confusing, your perl code just outputs html without any headers (like content-type). Your javascript doesn't seem to use jQuery, and none of the referred IDs appear anywhere in your example.
是你希望使用负荷类似: $ (#view_span')负载('filename_ajax.cgi');?
或者:
Were you looking to use load something like: $('#view_span').load('filename_ajax.cgi');
?
Or perhaps:
$('#view_span').load(
'filename_ajax.cgi',
{'target': escape(encodeURI('get_section'))},
alertViewResult);
这篇关于我如何使用Ajax使用jQuery在Perl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!