dongleiqiao2107 2014-11-16 00:48
浏览 52

Wordpress中的Jquery Ajax表单

jQuery(document).ready(function () {

    function loading_show() {
        $('#loading').html('<div id="overlay"><img id="leading" src="loader.gif"></div>').fadeIn('fast');
    }

    function loading_hide() {
        $('#loading').fadeOut('fast');
    }

    function loadData(page) {
        loading_show();
        var city = jQuery('#city').val();
        jQuery.post(
        MyAjax.ajaxurl, {
            action: 'MyAjaxFunction',
            city: city,
            page: page
        },

        function (msg) {
            loading_hide();
            jQuery("#container").html(msg);

        });

    }
    loadData(1); // For first time page load default results
    $(document).on('click', '#container .pagination li.active', function (e) {
        var page = $(this).attr('p');
        loadData(page);
    });
});

This is the ajax.js and uploaded into js folder. all functions are working expect var city value

<form id="search" method="post">
        <input id="city" name="city" placeholder="City">
       <button type="submit" id="submit">Submit</button>
</form>

I'm unable to get the input value into the Jquery. Please help

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?