Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.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
Javascript Ajax没有';无法使用.htaccess重写_Javascript_Php_Ajax_.htaccess_Fullcalendar - Fatal编程技术网

Javascript Ajax没有';无法使用.htaccess重写

Javascript Ajax没有';无法使用.htaccess重写,javascript,php,ajax,.htaccess,fullcalendar,Javascript,Php,Ajax,.htaccess,Fullcalendar,我有一个日历脚本,但似乎当我想通过ajax发送数据时,我得到了parserror,因为我通过htaccess更改了URL。我将代码放在一个测试项目中,而不更改URL,它可以工作,我如何修改代码,使其接受“filme”页面的更多参数。 我注意到它没有输入“success”,而是将数据添加到数据库中 .htaccess index.php PHP代码 完整代码 顺便说一句,请在PHP中创建一个对象,然后使用json_encode()生成json,这样就不太容易出错。如果成功地将所有数据添加到数据库中

我有一个日历脚本,但似乎当我想通过ajax发送数据时,我得到了
parserror
,因为我通过htaccess更改了URL。我将代码放在一个测试项目中,而不更改URL,它可以工作,我如何修改代码,使其接受“filme”页面的更多参数。 我注意到它没有输入“success”,而是将数据添加到数据库中

.htaccess index.php PHP代码 完整代码
顺便说一句,请在PHP中创建一个对象,然后使用json_encode()生成json,这样就不太容易出错。如果成功地将所有数据添加到数据库中,则向我建议发送参数不是问题?但如果它没有进入“成功”阶段,那么问题可能更多地在于它的反应。您是否查看了浏览器的网络工具以了解请求的结果?还是控制台的脚本错误?和/或PHP错误日志(假设已打开日志)?
RewriteEngine On

RewriteRule ^([a-zA-z0-9-]+)(\/)?(?(2)([0-9]+))$ index.php?pag=$1&id=$3 [NC,L]

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
<?php

    if(isset($_GET['pag']))
        switch($_GET['pag']){
            case ($_GET['pag'] == 'index'):
                include('pages/acasa.php');
                break;

            case 'filme':
                include('pages/filme.php');
                break;

            default:
                include('pages/eroare.php');
                break;
        }
    else
        include('pages/acasa.php');

?>
function doSubmit() {
    $("#createEventModal").modal('hide');
    var title = $('#title').val();
    var startTime = $('#startTime').val();
    var endTime = $('#endTime').val();

    $.ajax({
        url: 'pages/filme.php',
        data: 'action=add&title=' + title + '&start=' + startTime + '&end=' + endTime,
        type: "POST",
        success: function(json) {
            $("#calendar").fullCalendar('renderEvent', {
                    id: json.id,
                    title: title,
                    start: startTime,
                    end: endTime,
                },
                true);
        }
    });

}
if($_POST['action'] == "add")
    {
        mysqli_query($con, "INSERT INTO `filme` (
                    `title` ,
                    `start` ,
                    `end`
                    )
                    VALUES (
                    '".mysqli_real_escape_string($con, $_POST["title"])."',
                    '".mysqli_real_escape_string($con, date('Y-m-d H:i:s',strtotime($_POST["start"])))."',
                    '".mysqli_real_escape_string($con, date('Y-m-d H:i:s',strtotime($_POST["end"])))."'
                    )");
        header('Content-Type: application/json');

         echo '{"id":"'.mysqli_insert_id($con).'"}';
        exit;
    }
filme.php : https://pastebin.com/B8Cu4rRX
script.js : https://pastebin.com/gtR3SwSP