Что-то не так с этим кодом JQuery в WordPress - PullRequest
0 голосов
/ 25 ноября 2010

Я работаю над патчем 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 голосов
/ 26 ноября 2010

Может быть, вы должны попробовать это вместо jQuery('wp_error', child).each(function(){return this.size()});.Если он по-прежнему возвращает ноль, то проблема заключается в селекторе, в этом случае нет элемента wp_error, содержащего child, поэтому вам следует больше узнать, на что ссылается child (какую часть DOM он указал).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...