jQuery $.getJSON works only once for each control. Doesn't reach the server again

前端 未结 4 2016
Happy的楠姐
Happy的楠姐 2021-02-04 13:40

First my code

$.getJSON(\"./posts/vote/\" + postId + \"/1\", null, function(result) {
   if (result.result == true)
      $(\"#pst\" + postId + \" > .pstside          


        
4条回答
  •  广开言路
    2021-02-04 14:38

    You can do the same with GET request also, just add a timestamp at the end of the request for example see the below sample request

    http://www.abc.com/api/v1/votes?user=123&tag=jQuery&_timestamp=1234421352

    This way the browser will not cache your requests ever as the url will change on every call. You can get the timestamp from Javascript easily. Also you need not handle this timestamp at your server side, but that is upto your discretion.

提交回复
热议问题