如何在javascript中的window.location.href中传递变量值?

时间:2017-09-18 11:26:07

标签: javascript php

在此代码中运行良好并显示所有数据。这是一段javascript代码

checkoutCart:

function(products, totalPrice, totalQuantity) {
        var checkoutString = "Total Price: " + totalPrice + "\nTotal Quantity: " + totalQuantity;
        checkoutString += "\n\n id \t name \t summary \t price \t quantity \t image path";
        $.each(products, function(){
          checkoutString += ("\n " + this.id + " \t " + this.name + " \t " + this.summary + " \t " + this.price + " \t " + this.quantity + " \t " + this.image);
        });
    alert(checkoutString)

在这段代码之后,我想使用带有id传递的href属性。在使用alert函数之后然后按下ok按钮,之后我的href链接工作正常,但是在url bar中显示order.php?id = undefined。这是代码

window.location.href="order.php?id="+this.id ;

0 个答案:

没有答案
相关问题