Django的+ JQuery的阿贾克斯后 [英] Django + JQuery Ajax post
本文介绍了Django的+ JQuery的阿贾克斯后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看过的所有的主题,但我不明白什么是错的。
I have read all on the theme but I can't understand what's wrong.
$(document).ready(function() {
$.post("tweet.py", {
lat : searchResult._point.__lat,
lng : searchResult._point.__lng,
text : searchResult.text
}, function(data) {
alert(data);
});
});
该处理器的code:
The handler's code:
import django
def iEventAjax(request):
if request.is_ajax():
return HttpResponse("ok")
警报消息
"import django
def iEventAjax(request):
if request.is_ajax():
return HttpResponse("ok")
"
而不是OK
什么是错的?
推荐答案
请在你的urls.py中添加URL就像
Please add in your urls.py an url like
(r'^ajaxrequest$', 'app.views.iEventAjax')
再修改
$(document).ready(function() {
$.post("/ajaxrequest", {
lat : searchResult._point.__lat,
lng : searchResult._point.__lng,
text : searchResult.text
}, function(data) {
alert(data);
});
});
在你的你的应用程序的views.py
in your views.py of your app
def iEventAjax(request):
return HttpResponse("ok")
这篇关于Django的+ JQuery的阿贾克斯后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文