对PHP文件的AJAX请求,PHP文件未收到

时间:2016-03-17 09:19:59

标签: php jquery ajax

我正在尝试向PHP文件发送AJAX请求。 PHP文件没有收到请求。

我正在使用以下代码:

register.php:

$('#button_step1').click(function(e) {
        $.ajax({
            type: 'POST',
            url: '../core/views/cp/test.php',
            data: { message: 'works' },

            success: function(resp) {
                alert(resp);
            }
        });
        $('.step1 input').prop('disabled', true);
        window.location.replace("http://10.0.0.13/core/views/cp/test.php");
    });

test.php的:

<?php

echo $_POST['message'];

?>

我被重定向到test.php后得到的消息,“注意:第3行的C:\ xampp \ htdocs \ core \ views \ cp \ test.php中的未定义索引:消息”。

问题2:

当我require_once我的register_view.php包含AJAX请求到我的register.php并让它向register.php文件发送一个AJAX请求时,它会显示{ {1}}包含整个PHP文件中的所有数据,只显示“作品”。

代码,

register.php:

alert()

register_view.php:

<?php

require_once '../core/init.php';

$_SESSION['message'] = $_POST['message'];
echo $_SESSION['message'];

require_once VIEW_ROOT . '/cp/register_view.php';

1 个答案:

答案 0 :(得分:1)

SELECT * FROM traffic_info i LEFT JOIN traffic_info_archived a ON (i.info_id = a.info_id) INNER JOIN traffic_info_published p ON (i.info_id = p.info_id) LEFT JOIN traffic_info_read r ON (i.info_id = r.info_id) WHERE i.branch_id = 4 AND a.info_id IS NULL ORDER BY r.info_id IS NULL DESC, i.info_date_from ASC ; //您正在加载视图。你必须做这样的事情

require_once VIEW_ROOT . '/cp/register_view.php';
相关问题