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

Passing data using post in the JQuery load method

本文关键字:post 数据 JQuery 加载 方法      更新时间:2023-09-26

我正在使用以下代码将数据传递到Django应用程序中的视图,但对于一些有能力的人来说,我无法在视图中访问它。要么我传错了,要么我试图错误地访问它,我想知道你们是否能帮我。

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

视图:

pageNum = request.POST['pageNum']

谢谢!

.load()使用GET,如果你想发送帖子,$.post()就是你想要的:

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