简体   繁体   中英

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. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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