我正在使用ajax将数据传递到python脚本,但无法获取该数据。我设法得到的最多是“未定义”或脚本文本本身(不知道为什么...)。目前,经过大量尝试,我什么也没得到。
我不知道这是否相关,但是我是python的新手,并且不想使用任何框架,因此我正在使用SimpleHTTPServer。反正...
这是ajax电话
$(function(){
$.ajax({
type: "GET",
url: "con-test.py",
dataType: "json",
success: function (responseText) {
alert(responseText); /* responseText.stuff is not working either */
}
});
});
和脚本con-test.py
import json
result = {}
result['stuff'] = 'banana'
json_string = json.dumps(result)
print result # also tried return result
Helenr
相关分类