Django/AJAX/JQuery - Simple POST troubles

I'm trying to implement the simplest AJAX POST I can think of because I'm new to AJAX and JQuery. The idea is this: I have a button, and when it is clicked I want to submit basic POST data to the same page (the page is: http://{{ my ip address }}/django/ajax/ ). In my .html file I have:
And my relevant function in is: def ajax(request): if request.method == 'POST': return HttpResponse("Hello AJAX") return render_to_response('huh.html', {}) Simple, right? The problem however, is that when I click my button, the "it SHOULD post after this is appended" is successfully added to the div, but nothing else happens, HttpResponse("Hello AJAX") is not returned, the POST isn't working! What I've written seems consistent with the documentation I've read, but I have a feeling I'm either missing something stupid, or trying to oversimplify the POST. Thanks in advance!
Do you have a JS error? Maybe the JS var "data" is undefined.

以上就是Django/AJAX/JQuery - Simple POST troubles的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准