wordpress中的这个jQuery代码出了点问题

时间:2010-11-25 17:41:14

标签: javascript jquery xml wordpress

我正在使用Wordpress补丁。

这就是XML

<?xml version='1.0' standalone='yes'?><wp_ajax><response action='autosave_1'><wp_error id='1' position='1'><response_data><![CDATA[<p>
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>localhost</code>. This could mean your host's database server is down.</p>
<ul>
    <li>Are you sure you have the correct username and password?</li>
    <li>Are you sure that you have typed the correct hostname?</li>
    <li>Are you sure that the database server is running?</li>
</ul>
<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
</p>]]></response_data><supplemental></supplemental></wp_error></response></wp_ajax>

解析上述XML的脚本:wp-ajax-response.dev.js

问题是:即使对于具有jQuery('wp_error', child).each().size()标记的上述XML,<wp_error>也始终返回零。

为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

也许你应该试试jQuery('wp_error', child).each(function(){return this.size()});。如果它仍然返回零,那么问题出在选择器上,在这种情况下,wp_error元素没有包含child,所以你应该更多地检查child所指的位置(什么)它指出的DOM的一部分。