javascript - POST AJAX request throws 501 not implemented -


problem: receive 501 not implemented error when attempting post request. get method works fine, data length limit makes nonviable xml string wish pass in php script.

background: i'm generating xml string based on user inputs javascript. next, i'm trying pass xml string (after encoding it) php script write string xml file on server , execute command regarding it.

server: 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 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"); ?> 

thanks!


Comments