正确编码href链接(JSON.parse(results))错误

时间:2015-01-08 12:42:09

标签: php json

foreach ($listItems as $listItem)
{

        $results['args1'] = '<a href="'. $listItem->attributes->getNamedItem('href')->value .'">'.$listItem->attributes->getNamedItem('href')->value.'</a>';
        $results['args2'] = '1';
}

输出: alert(results);

{"args1":"<a href=\"http:\/\/www.spire.com\/\">http:\/\/www.spire.com\/<\/a>","args2":"1"}

{"args1":"<a href=\"http:\/\/www.spire.com\/\">http:\/\/www.spire.com\/<\/a>","args2":"1"}

{"args1":"<a href=\"http:\/\/www.spire.com\/\">http:\/\/www.spire.com\/<\/a>","args2":"1"}

我怎样才能正确识别上述href链接。我认为href链接导致成功函数中的JSON.parse(结果)错误。

ajax成功:

success: function(results)
{
    var results = JSON.parse(results);

    $('.linksPaste').html(results.args1);
}

0 个答案:

没有答案
相关问题