Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试获取正确的get链接,该链接显示shoppingcart中的好信息_Php_Javascript_Jquery - Fatal编程技术网

Php 尝试获取正确的get链接,该链接显示shoppingcart中的好信息

Php 尝试获取正确的get链接,该链接显示shoppingcart中的好信息,php,javascript,jquery,Php,Javascript,Jquery,好的,这是我在网上搜索了几个月后的问题。我想从jquery获得正确的链接,以获取正确的div并在页面上显示它们。现在,这些文件以GET作为根 我有两份档案 shopping_cart.php和jquery-oscart.js jquery-oscart.js $.ajax({ type: 'POST', url: encodeURI($(location).attr('href')) + '&action=update_product&ajax=1',

好的,这是我在网上搜索了几个月后的问题。我想从jquery获得正确的链接,以获取正确的div并在页面上显示它们。现在,这些文件以GET作为根

我有两份档案

shopping_cart.php和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); }); 在正常状态下没有问题

这是我的问题

在执行文件时,Firefox为我提供了以下规则:

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 返回(假); });

它提供了链接:

domain/index.php&ajax=1

而不是

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&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 domain../index.php?option=com\u oscommerce&osMod=shopping\u cart&Itemid=2&action=update\u product&ajax=1

可能是“形式”的东西吗?似乎它将我发送到index.php而不是index.php?option=com\u oscommerce&osMod=shopping\u cart

问题解决了吗?选项链接被隐藏。我得到的另一份文件显示出来了。现在帖子链接很好。我唯一遇到的问题是GET链接

似乎url:encodeURI($('form[name=cart\u quantity')).attr('action'))+'&ajax=1'

获取一个帖子的2个链接。返回的链接在结尾处错过了&ajax=1

试试看

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

(I put&action=blahblah inside encodeURI)

问题可以通过在url中添加+'format=ajax'来解决

比如:


不幸的是,这没有帮助。没有什么变化。当我删除action=update\u product&GET规则消失时,那会是什么?看起来所有的请求都应该是post。也许用户正在单击一个按钮来激活请求,但是按钮的默认操作(提交表单)也在发生?调用$ajax调用的javascript应该返回false或preventDefault。
 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();
        }
    });
url:  encodeURI($(location).attr('href') + '&action=update_product&ajax=1'),
    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();
        }
    });