Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法在wordpress自定义插件中使用jquery ajax post方法在页面上发布值_Php_Jquery_Ajax_Wordpress - Fatal编程技术网

Php 无法在wordpress自定义插件中使用jquery ajax post方法在页面上发布值

Php 无法在wordpress自定义插件中使用jquery ajax post方法在页面上发布值,php,jquery,ajax,wordpress,Php,Jquery,Ajax,Wordpress,我是wordpress的新手,我刚刚创建了我的第一个插件。这个插件包含一个表单。每当我发出jQueryAjax Post请求提交表单时,我都会在警报框中看到这个错误 Call to undefined function add_shortcode() in <b>J:\xampp\htdocs\wordpress\wp-content\plugins\auc_result_fetcher\includes\search.php</b> on line <b>2

我是wordpress的新手,我刚刚创建了我的第一个插件。这个插件包含一个表单。每当我发出jQueryAjax Post请求提交表单时,我都会在警报框中看到这个错误

Call to undefined function add_shortcode() in <b>J:\xampp\htdocs\wordpress\wp-content\plugins\auc_result_fetcher\includes\search.php</b> on line <b>22</b><br />

请帮帮我。谢谢

你确定那是wordpress 1.3.8还是3.8.1?对不起。我的错误。它的Wordpress 3.8.1。最新版本。我只是用正确的版本编辑了我的文章。不管jquery调用什么,它都不会调用定义短代码的地方,因此未定义的errorWordpress提供了处理ajax请求的功能。请提供您的代码片段。
add_action('init', function() {
  add_shortcode('search_form', 'print_search_form');
});

add_action('init', 'fetch_grades');
add_action('init', 'fetch_search_options');


function print_search_form(){



?>
    <div class="auc-search-form">
    <div id="error">

    <div id="select-class-error"></div>
    <div id="select-search-by-error"></div>
    <div id="search-field-error"></div>

    </div>
    <form id="searchForm" method="POST" action="">
    <table>
        <tr>
        <td style="text-align:right;"> <span>Class:</span> </td>
        <td><select id="select-class" name="search-class">
        <option>Select Class</option>
        <?php

        $grades = fetch_grades();
        foreach($grades AS $v){
            echo "<option>".$v->grade_title."</option>";
        }
        ?>
        </select>
        </td>
        <td id="class-select"></td>
       </tr>
       <tr id="previous-row">
        <td style="text-align:right;"> <span>Search By:</span> </td>
        <td>
           <select id="search-by" name="search-by">
            <option>Select Choice</option>
            <?php

            $grades = fetch_search_options();
            foreach($grades AS $v){
              echo "<option>".$v->search_title."</option>";
            }
            ?>
           </select>
        </td>

       </tr>
       <tr id="search-row">
            <td id="search-by-option-label" style="text-align:right;"><span></span></td>
        <td id="search-by-field"><input type="text" name="searchBy" id="search" /></td>
       </tr>
       <tr >
        <td ></td>
        <td>
          <input type="hidden" id="url" name="url" value="<?php echo SEARCH_RESULTS; ?>">
          <input type="button"  id="search-button" value="Search" />
          <input type="reset" name="searchBy" id="reset" value="Cancel"/>
        </td>
       </tr>
    </table>
    </form>
</div>
<?php
}