я новичок в jquery. Я делаю ajax, используя jquery в django.
$(document).ready(function() {
$.getJSON('/jsonserver/', function(json){
alert("JSON Data: " + json);
});
Вышеупомянутый jquery работал для меня.Когда я вставляю ту же кнопку в функцию click, она успешно вызывает URL, но предупреждение не отображается.
$(document).ready(function() {
$('#save').click(function(){
$.getJSON('/jsonserver/', function(json){
alert("JSON Data: " + json);
});
});
});
<form method ="POST" method =/jqueryserver/ name ="form1" id ="form1">
<input type= "submit" id = "save" name ="save" value ="Save" />
</form>
view.py
def jsonserver(request):
print "...jsonserver..."
json = simplejson.dumps('hello world!')
return HttpResponse(json, mimetype = 'application/json')