X-Editable Successfully POST; However, POST.PHP isn't instantiated

334 views Asked by At

Two days of debugging and research and I could use some help with an x-editable problem. I'm using the x-editable library to effect inline editing of select fields. A network trace shows that the POST to the POST.PHP function is successful (200) and PK, NAME, and Variable are correctly sent via the POST request.

That said, it would appear as though the post program isn't instantiating. I've placed several echo and var_dump commands as the first executable statements and there is no response or output provided to the window or console. The only response is when I open the POST program via the browser; wherein, I get undefined index errors.

I would appreciate any insights and assistance.

<a href="#" id="course_provider" class="editable-select" data-pk="<?php echo $course_id ?>" data-value="<?php echo $course_provider ?>"><?php echo $course_provider ?></a>

    $('#course_code').editable();
$('#course_institution').editable();
$("#course_provider").editable({
    type:       'select',
    title:      'Select provider',
    placement:  'right',
    ajaxOptions: { type: 'POST'},
    source: [
        {value: "UVA",        text: "UVA"},
        {value: "JMU",       text: "JMU"},
        {value: "UPENN",     text: "UPENN"},
        {value: "LSU",          text: "LSU"}
    ],
    url:        '../public/post_course.php'
});

THE POST SCRIPT

require("../includes/config.php");

define("TITLE", "Post Course Updates");

var_dump($_POST);    

echo "entering post...";

/*
You will get 'pk', 'name' and 'value' in $_POST array.
*/
$pk = $_POST['pk'];
$name = $_POST['name'];
$value = $_POST['value'];
/*
 Check submitted value
*/

if(!empty($pk)) 
{

    $link = mysqli_connect("SERVER", "USERNAME", "PASSWORD", "DATABASE");

    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    $course_id = mysqli_real_escape_string($link, $pk);
    $field_name = mysqli_real_escape_string($link, $name);
    $field_value = mysqli_real_escape_string($link, $value);

    //  $result = mysql_query('update users set '.mysql_escape_string($name).'="'.mysql_escape_string($value).'" where user_id = "'.mysql_escape_string($pk).'"');
    if ($result = mysqli_query($link, 'UPDATE courses set '.$field_name.'="'.$field_value.'" where course_id = "'.$pk.'"'))
    {
        echo "Update successfull";
    }

    mysqli_close($link);
    print_r($_POST);
} 
else 
{
    /* 
    In case of incorrect value or error you should return HTTP status != 200. 
    Response body will be shown as error message in editable form.
    */
    header('HTTP 400 Bad Request', true, 400);
    echo "This field is required!";
}

?>

0

There are 0 answers