开发者

Send data from python-cgi to AJAX

I'm implementing a UI version of the find command in linux. I take the location and filename parameters for the find command in a cgi form implemented using python. On submit, I draw the form again and want to display the results in a div.

My issue is that the server times out 开发者_JAVA百科if the find command takes too much time. So I'm trying to dynamically get the results and display them on the ui.

On the server side I'm using the below code to dynamically get the results:

*cmd = subprocess.Popen(["find", location ,"-name", file_name], stdout=subprocess.PIPE)

for line in cmd.stdout:
    results.append(line.rstrip("\n"))*

From java script side I'll draw the table dynamically using innerHTML.

I thought of passing the value of results from server to client by using an AJAX call, say every 5 seconds. I'm new to this and would appreciate if anyone could help me by showing me how to do the AJAX part, if it is possible to get the value of a python variable from the client side.


Refer to this one:

http://www.degraeve.com/reference/simple-ajax-example.php

Hope it helps....

In server side, instead of storing on variable, try to store it on a file so that your python method can give it back the latest dynamic search results to every AJAX call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜