社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

使用WordPress重定向jquery url

Hassan Shahzad aAheer • 6 年前 • 723 次点击  

让我给你看代码

马尼锉 index.php索引

<?php
global $wpdb;
$data = $wpdb->get_results ( "SELECT * FROM wp_people" );?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="<?php echo get_template_directory_uri() . '/jquery.tabledit.js' ?>"></script>

</head>
<script type="text/javascript">

$(document).ready(function(){

$('#example1').Tabledit({
    url: 'logic-edit-delete.php',
    columns: {
        identifier: [0, 'id'],
        editable: [[1, 'name'], [2, 'email'], [3, 'location'],[4, 'IG_handle'],[5, 'website']]
    },
    onDraw: function() {
        console.log('onDraw()');
    },
    onSuccess: function(data, textStatus, jqXHR) {
        console.log('onSuccess(data, textStatus, jqXHR)');
        console.log(data);
        console.log(textStatus);
        console.log(jqXHR);
    },
    onFail: function(jqXHR, textStatus, errorThrown) {
        console.log('onFail(jqXHR, textStatus, errorThrown)');
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
    },
    onAlways: function() {
        console.log('onAlways()');
    },
    onAjax: function(action, serialize) {
        console.log('onAjax(action, serialize)');
        console.log(action);
        console.log(serialize);
    }
    });


});

</script>
<style>

.table.user-select-none {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
</style>

</head>
<body>

 <div class="container" style="margin-top:80px;">
    <div class="panel panel-default">
        <div class="panel-heading">

        </div>

                <div class="panel-body">
                    <table class="table" id="example1" style="border:1px solide red">
                        <tr>
                            <th>Id</th>
                            <th>Name</th>
                            <th>Email</th>
                            <th>Location</th>
                            <th>IG_Handel</th>
                            <th>Website</th>
                            <th>Action</th>
                            </tr>
                      <?php foreach ($data as $people): ?>
                        <tr>
                        <td><?php echo $people->id;?></td>
                        <td><?php echo $people->name; ?></td>
                        <td><?php echo $people->email; ?></td>
                        <td><?php echo $people->location;?></td>
                        <td><?php echo $people->IG_handle; ?></td>
                        <td><?php echo $people->website; ?></td>
                        </tr>
                         <?php endforeach; ?>

                    </table>
                    </div>
                </div>
    </div>
  </div>
</body>
</html>

<?php

$input = filter_input_array(INPUT_POST);

if ($input['action'] === 'edit')
{
    ?>
    <script type="text/javascript">
        alert("welcome");
    </script>
    <?php
    $wpdb->update( 'wp_people',
        array(
            'name' => '$input[name]',
            'email' => $input['email'],
            'location' => $input['location'],
            'IG_handle' => $input['IG_handle'],
            'website' => $input['website']
        ),
        array( 'id' => $input['id'] ),
        array( '%s','%s','%s','%s','%s' ) );


}

jquery代码文件链接 enter link description here

enter image description here

请帮助我如何重定向到该页我,也可以试试这些

url: '<?php echo admin_url('admin-ajax.php'); ?>',

在jquery中

非常感谢你

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57304