JS variable.new是什么意思?

时间:2013-11-28 13:53:07

标签: javascript json internet-explorer-8

function controlPackage(action, row, txt, params) 
{
    alert("STOP1");
    clearTimeout(pollClientTableTimer);
    if ( confirm(txt.confirm) ) 
    {
        showActivityBar(txt.activity);
        $.getJSON("ajax_requests/controlPackage.php",
        { 
            id: params.pkg_id, 
            date: params.activate_date, 
            'action': action, 
            'new': params.new 
        },
        function(data)
        {
            var is_error = data.code == 400 ? 1 : 0;
            pollClientTable(pollClientTableTimerPoll, false);
            var msg = data.message;
            for ( var i in data.errors ) 
            {
                msg += "<br/>\u2022 "+data.errors[i];
            }
            closeActivityBar();
            setMessage(msg, is_error);
        });
    } 
    else 
    {
        pollClientTable(pollClientTableTimerPoll, true);
    }
}

我有这个功能,这是在我接管产品之前开发的,我不清楚的是params.new的意思。

问这个的原因是因为我在IE8中得到了一个预期标识符错误,指向代码中的这一行。

params是一个JSON编码:

$params = $json->encode(array("pkg_id"=>$clientPackage->getId(), "activate_date"=>$clientPackage->getActivationDate()));

所以我问的是params.new是什么意思,为什么会抛出这个错误。

2 个答案:

答案 0 :(得分:1)

params.new只是new对象上名为params的属性(不幸的是在那里命名)。

您应该使用params["new"]访问它以避免错误。名称new存在问题,因为它是name of an operator in JavaScript

如果您可以控制该属性的名称,我建议您更改它。

答案 1 :(得分:0)

params似乎是一个JSON对象,它具有不同的属性(例如,activate_date,action,new)。