简体   繁体   English

在JQuery加载方法中使用post传递数据

[英]Passing data using post in the JQuery load method

I'm using the following code to pass data to my view in my Django app, but for some able am not able to access it in the view. 我正在使用以下代码在Django应用中将数据传递到视图,但是对于某些无法在视图中访问它的人。 Either I'm passing it incorrectly, or am trying to access it incorrectly, and was wondering if you guys could help me out. 我是错误地传递了它,还是试图错误地访问它,并且想知道你们是否可以帮助我。

jQuery("#garbage").load(
    '/search/loadBottomLooks/',
    {'pageNum':2},
    function(responseText, responseStatus) {
        alert('got into the callback');
    }
)

View: 视图:

pageNum = request.POST['pageNum']

Thanks! 谢谢!

.load() uses GET, $.post() is what you're looking for if you want to send a post: .load()使用GET, $.post() post $.post()是您要发送帖子的内容:

 $.post("/search/loadBottomLooks/", 
 { pageNum: "2" },
 function(responseText, responseStatus){ 
      alert('got into the callback!'); 
      $("#garbage").html(responseText);
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM