Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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 POST AJAX请求抛出501未实现_Javascript_Php_Ajax_Post - Fatal编程技术网

Javascript POST AJAX请求抛出501未实现

Javascript POST AJAX请求抛出501未实现,javascript,php,ajax,post,Javascript,Php,Ajax,Post,问题:我在尝试POST请求时收到一个501未实现错误。GET方法工作得很好,但是它的数据长度限制使得我希望传递给PHP脚本的XML字符串不可用 背景:我正在使用JavaScript根据一些用户输入生成一个XML字符串。接下来,我尝试将这个XML字符串(编码后)传递给PHP脚本,将字符串作为XML文件写入服务器,并执行一个与之相关的命令 服务器:Apache/2.4.6(CentOS)OpenSSL/1.0.1e-fips PHP/5.4.16 JS: $.ajax({

问题:我在尝试
POST
请求时收到一个501未实现错误。
GET
方法工作得很好,但是它的数据长度限制使得我希望传递给PHP脚本的
XML
字符串不可用

背景:我正在使用JavaScript根据一些用户输入生成一个XML字符串。接下来,我尝试将这个
XML
字符串(编码后)传递给PHP脚本,将字符串作为
XML
文件写入服务器,并执行一个与之相关的命令

服务器:Apache/2.4.6(CentOS)OpenSSL/1.0.1e-fips PHP/5.4.16


JS:

        $.ajax({
            type: "POST",
            url: 'Submit_Job_to_Computer_Cluster.php',
            data: 
            {
                XML_requested_job: XML_String
            },
            dataType: "text",
            success: function(msg) 
            {
                console.log(msg);
                alert("success");
            },
            error: function(xhr, ajaxOptions, thrownError) 
            {
                console.log(xhr.status);
                alert(xhr.responseText);
                alert(thrownError);
            }
        });
    }
PHP(5.4.16):

<?php

switch ($_SERVER['HTTP_ORIGIN']) {
    case 'http://from.com': case 'https://from.com':
    header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
    header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
    header('Access-Control-Max-Age: 1000');
    header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
    break;
}

$XML_string = $_POST["XML_requested_job"]; //passed in string

try{
$XML_file= "workflowPROD.xml";
$file_handle = fopen($XML_file, 'w') or die("Can't open the file");
fwrite($file_handle, $XML_string);
fclose($file_handle);
} catch (Exception $e) {
}

$today = getdate();
$year = (string) $today['year'];
$month = (string) $today['month'];
$day = (string) $today['mday'];
$db_path = " /tmp/";
$db_path .= $year;
$db_path .= $month;
$db_path .= $day;
$db_path .= ".db";

$rocoto_path = "/work/apps/gnu_4.8.5/rocoto/1.2.1/bin/rocotorun";

//concatenate command
$exec_command = $rocoto_path;
$exec_command .= " -w ";
$exec_command .= $XML_file;
$exec_command .= " -d";
$exec_command .= $db_path;
shell_exec($exec_command);
echo ("SUCCess"); ?>

未实现意味着库/框架不支持您尝试执行的操作。您正在运行哪个PHP版本?什么httpd服务器,版本?某些托管公司阻止POST方法。它可能与此相关:。我注意到你在PHP中检查了主机,所以也许你是远程发布的?要检查@frz3993点,设置一个本地WAMP/LAMP服务器,它不会有这样的限制。我刚刚更新了我的帖子,包括了服务器和PHP版本。未实现意味着库/框架不支持你正在尝试的操作。您正在运行哪个PHP版本?什么httpd服务器,版本?某些托管公司阻止POST方法。它可能与此相关:。我注意到你在PHP中检查了主机,所以也许你是远程发布的?要检查@frz3993点,设置一个本地WAMP/LAMP服务器,它不会有这样的限制。我刚刚更新了我的帖子,并包含了服务器和PHP版本