从一个动态页面到另一个动态页面获取详细信息-重新发布 [英] Getting Details from one Dynamic Page to Another - Re-Post

查看:119
本文介绍了从一个动态页面到另一个动态页面获取详细信息-重新发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相信几乎为JoomShopping组件编写的每一行代码后,我都发现应该解决所有麻烦.

After some wrestling with almost every line of code written for the JoomShopping component I beleive I have found what should be the answer to all my woes.

在购物清单中激活购买"按钮并单击后,使用以下链接语法将产品发布到结帐购物车:

When activating the "Buy" button in the shopping list and once clicked on it uses the following link syntax in order to post a Product to the Checkout Cart:

index.php/cart/add?category_id=2&product_id=12&quantity=4

其中2是类别ID,12是产品ID等...这已由V.Vachev解决,但我认为在可行的情况下发布所有完成/固定的oced是谨慎的:

Where 2 is the Category ID and 12 is the Product ID etc ... This was solved by V.Vachev, but I thought it prudent to post all of the finished/fixed oced as it works:

    $('.checkOut').live('click',function(){
    var products= new Array();
$(".jshop_prod_cart").each(function(){
    var product = new Object();
        product.catid = $(this).find('[name="category_id"]').val();
            product.id = $(this).find('input[name="product_id"]').val();
            product.qanty = $(this).find('input[name^="quantity"]').val();
    products.push(product) 
    $.ajax({
                    type: 'GET',
                url: "shop-portal/add?category_id="+products[0].catid+"&product_id="+products[0].id+"&quantity="+products[0].qanty,
                    dataType: 'json',
                    })

        })
    })

这将返回:

http://www.domain.com/index.php/shop-portal/add?category_id=2&product_id=48&quantity=4

但是它只返回1,我有多个动态条目,所有这些条目都必须照此捕获.

BUT it is only returning the 1 and I have multiple dynamic entries which all need to be captured as such.

我正在对此进行研究,似乎我需要以某种方式缓存此信息...有什么想法吗?

I am researching this, it seems I need to cache this information somehow ... Any ideas?

推荐答案

URL传递不正确.应该是这样的:

URL passing wasn't correct. It should be like that:

    url: "/shop-portal/add?category_id="+catid+"&product_id="+id+"&quantity="+qanty,

现在,我看到您具有相同名称的数组("catid","quantity" ...).您最终是否要从数组发送值?因为这是另一回事.确保"catid","id"和"qanty"是全局变量,并发送所需的值.

Now I see that you have array with the same names ("catid", "quantity" ...). Do you eventually want to send the values from the array? Because this is another thing. Make sure that "catid", "id" and "qanty" are global variables and you send the desired values.

Joomla可能不希望使用JSON数据,请尝试使用本机Ajax请求

Joomla is probably not expecting JSON data, try with native ajax request

var xmlhttp;
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    alert("Sent!");
    }
  }
xmlhttp.open("GET","/shop-portal/add?category_id="+yourvariable+"&product_id="+yourvariable+"&quantity="+yourvariable);
xmlhttp.send();

我不确定您要发送什么值.照顾好他们(yourvariable1,yourvariable2 ...)

I'm not sure what values you want to send. Take care of them (yourvariable1, yourvariable2...)

现在,我看到您想从数组中传递值.尝试

Now I see that you want to pass values from the array. Try with

  $.ajax({
    type: 'GET',
    data:products,
    url: "/shop-portal/add?category_id="+products[0].catid+"&product_id="+products[0].id+"&quantity="+products[0].qanty,
    dataType: 'json',
    })
})

此请求将仅发送第一个产品的值.产品是一个数组,因此您可能必须遍历它并发送多个请求才能发送所有内容.

This request will send only the values from the first product. Products is an array so you probably must loop thru it and send multiple requests in order to send everything.

您可以使用console.log(products)检查var产品"包含什么.这将在控制台中显示内容(例如Firebug).

You can check what does the var "products" contain with console.log(products) .This will display the content in the console (Firebug for example).

$('.checkOut').live('click',function(){
var products= new Array();
        $(".jshop_prod_cart").each(function(){
            var product = new Object();
        product.catid = $(this).find('[name="category_id"]').val();
        product.id = $(this).find('input[name="product_id"]').val();
        product.qanty = $(this).find('input[name^="quantity"]').val();
        products.push(product) 


                         $.ajax({
                        type: 'GET',
                        data:products,
                        url: "/shop-portal/add?category_id="+product.catid+"&product_id="+product.id+"&quantity="+product.qanty,
                        dataType: 'json',
                        })
            })


});

这篇关于从一个动态页面到另一个动态页面获取详细信息-重新发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆