将ajax响应存储在全局变量中

时间:2014-03-26 03:46:37

标签: javascript jquery

似乎无法得到此ajax帖子的回复

  $("#btn_update_shipping_cost").click(function(e){
       var new_freight = 0;

       $.post("/action.shipping.cost.php?page=get-adjusted-freight",{
          current_weight : current_weight,
          shipping_country:shipping_country
       },
       function(result){
          new_freight = result;
       });
    });

1 个答案:

答案 0 :(得分:0)

$(document).ready(function(){
var new_freight = 0;

$("#view_report").click(function(){
  $("#btn_update_shipping_cost").click(function(e){

       $.post("/action.shipping.cost.php?page=get-adjusted-freight",{
          current_weight : current_weight,
          shipping_country:shipping_country
       },
       function(result){
          new_freight = result;
       });
    });
});