dsfw2154 2009-11-02 10:21
浏览 10

在jquery中刷新页面时不会获得价值

When I click on link the value displayed correctly.But when I refresh the page i don't get this value.

I have written below code

$j("#add_to_cart_action").click(function(e) {
      $j.em.cart.addSelectedTitle();
    });

$j.em.cart.addSelectedTitle = function() {
  var addcartitemindx = $j("body").data("selected_title").product_id;
  var indx = $j("body").data("selected_title").cindex;
  var addcartitemtitle = $j("body").data("selected_title").ctitle;
  if ($j('input#chkout_'+addcartitemindx).length > 0) {
    alert('Shopping Cart Notification:
 "'+addcartitemtitle+'" is already added.');
    return false;
  }

 $j('#checkout_form ul').prepend('<li><input checked="true" type="checkbox" id="chkout_'+addcartitemindx+'" name="product[]" class="added-item" value="'+addcartitemindx+'"/><a href="javascript:$j.em.cart.TriggerCartItem('+indx+');">'+addcartitemtitle+'</a></li>');
  $j.em.cart.setCartDisplay();
};

I want to store addcartitemtitle in cookie so that i can restore so please give me the syntax to write it in jquery.

  • 写回答

2条回答 默认 最新

  • duannengling4705 2009-11-02 10:33
    关注

    If you mean Items in cart are not displayed on refreshing then you need either store them on user's side using cookies or store on server when adding to cart so that on refreshing you can restore them.

    you need to identify the which items belong to cart on which machine, you can use cookie to identify machine if you store selected items on server. If the your users have to register and login to select items then you can put items in cart into a db and associate them with user id. Now wherever user logs in you can get items associated with his/her id and display in cart.

    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教