Something's wrong with this jQuery code in wordpress
I'm working on a Wordpress patch.
Thi开发者_如何学运维s is what the XML is
<?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>
And the script which parses the above XML: wp-ajax-response.dev.js
The problem is: jQuery('wp_error', child).each().size()
is always returning zero even for the above XML which has the <wp_error>
tag.
Why would this happen?
Maybe you should try this instead jQuery('wp_error', child).each(function(){return this.size()});
. If it's still returning zero then that the problem is with the selector, in this case there are no wp_error
element contained child
, so you should check more on where child
is referring to (what part of DOM it pointed).
精彩评论