开发者

Try to get the right GET link which shows the good info in shoppingcart

开发者 https://www.devze.com 2023-03-04 03:18 出处:网络
Ok here is my problem after months of searching over the internet.I want to get the right link from jquery to take the right div and show them on the page. For now the files takes the root with GET

Ok here is my problem after months of searching over the internet. I want to get the right link from jquery to take the right div and show them on the page. For now the files takes the root with GET

I got 2 files.

shopping_cart.php and jquery-oscart.js

jquery-oscart.js

     $.ajax({
      type: 'POST',
       url:  encodeURI($(location).attr('href')) + '&action=update_product&ajax=1',
      data: $('form[name=cart_quantity]').serialize(),
      async:false,
      success: function(data) {
        $("#content-body").html(data);
        //Hide_Load();
        //update_cart();
      },
      dataType: 'html'
    });
    // Updating cart total
    //
    $.ajax({
        type: 'POST',
      url:  encodeURI($(location).attr('href')) + '&action=update_product&show_total=1&ajax=1',
        data: $('form').serialize(),
        success: function(data) {
            $('#boxcart-total').html(data);
            //Hide_Load();
            }
        });
  return(false);
});

The action: .attr('action')

The div that show up should be #content_body from the shoppingcart file.

In the shoppingcart.php file there is an action that calls:

<script type="text/javascript" src="js/jquery-oscart.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

In normal state there is no problem.

here is my question.

When execute the files Firefox gives me the following rules:

POST domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&action=update_product&ajax=1

GET domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2

POST domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&action=update_product&show_total=1&ajax=1

GET domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2

instead of

POST domain../index.php?option=com_oscommerce&osMod=shopping_cart&Ite开发者_运维问答mid=2&action=update_product&ajax=1

GET domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&ajax=1

POST domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&action=update_product&show_total=1&ajax=1

GET domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&show_total=1&ajax=1

In the GET. I miss &ajax=1 and &show_total=1&ajax=1

Something had to be changed in the jquery_oscart.js but I don't know where to change...

I tried the .load function with the right link but that's not a solution.

I hope someone can help me with this.


The original code is:

 jQuery.ajax({
  type: 'POST',
  url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&ajax=1', 
 data: jQuery('form[name=cart_quantity]').serialize(),
    success: function(data) {
   jQuery("#content-body").html(data); 
    //Hide_Load();
    //update_cart();

}
});
// Updating cart total

jQuery.ajax({
   type: 'POST',
url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&show_total=1&ajax=1', 
   data: jQuery('form').serialize(),
     success: function(data) {
        jQuery('#boxcart-total').html(data); 
        //Hide_Load();
        }
    });

return(false); });

it gives the link:

domain/index.php&ajax=1

instead of

domain../index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2&action=update_product&ajax=1

Could it be something with the 'form'? It seems it send me to index.php instead of index.php?option=com_oscommerce&osMod=shopping_cart

Problem solved the ? option... link was hidden. With another file I get is showed. Now the POST links are fine. The problem I only got is the GET link.

It seems url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&ajax=1',

Gets 2 links a POST en ea returning GET. The returning link missed the &ajax=1 at the end.


Maybe try

url:  encodeURI($(location).attr('href') + '&action=update_product&ajax=1'),

(I put &action=blahblah inside encodeURI)


Problem could be solved by adding + 'format=ajax' in the url

like:

    jQuery.ajax({
  type: 'POST',
  url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&format=ajax'+ '&ajax=1', 
 data: jQuery('form[name=cart_quantity]').serialize(),
    success: function(data) {
   jQuery("#content-body").html(data); 
    //Hide_Load();
    //update_cart();

}
});
// Updating cart total

jQuery.ajax({
   type: 'POST',
url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&format=ajax'+ '&show_total=1&ajax=1', 
   data: jQuery('form').serialize(),
     success: function(data) {
        jQuery('#boxcart-total').html(data); 
        //Hide_Load();
        }
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消