gpt4 book ai didi

jquery - AJAX 发布到 Python cgi

转载 作者:搜寻专家 更新时间:2023-10-31 02:24:50 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Post JSON to Python CGI

我已经安装了 Apache2 并且 Python 正在运行。

不过我遇到了问题。我有两个页面。

一个是 Python 页面,另一个是带有 JQuery 的 Html 页面我无法将 Src 粘贴到 google jquery 链接。

谁能告诉我如何让我的 ajax 帖子正常工作。

    $(function()
{
alert('Im going to start processing');

$.ajax({
url: "saveList.py",
type: "post",
data: {'param':{"hello":"world"}},
dataType: "application/json",
success : function(response)
{
alert(response);
}
});
});

和 Python 代码

import sys
import json

def index(req):
result = {'success':'true','message':'The Command Completed Successfully'};

data = sys.stdin.read();

myjson = json.loads(data);

return str(myjson);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com