MouseUp上的Ajax请求,500内部服务器错误

时间:2014-01-28 12:34:38

标签: jquery ajax

我有这段代码将数据发送到文件aaa.php以存储到数据库中。它基本上是你选择的任何数据都必须转到后端。

现在我将数据存储在名为st的变量中。它是一个数组,其中st [0]基本上包含文本。

当我执行代码

时,我收到内部服务器错误500

代码如下

var getSelected = function()
{
    var t = '';
    if(window.getSelection)
    {
        t = window.getSelection();
    s = window.getSelection().toString().length;
    //alert(s);
    element = window.getSelection().anchorNode.parentNode;
      //alert(element);

  }

    else if(window.selection)
    {
        t=window.selection.createRange();


    }
    return [t,s,element];



}


$(document).ready(function(){

    $(document).bind("mouseup",mouseup);

    $(document).bind("mousedown",mousedown);

});


var mouseup=function(){


        //$('div#pop-up').show();


        var st = getSelected();
         //alert(st[2]);
        alert(st[0]);
        var dataAnn = st[0]
//});


$.ajax(
{
    url : 'aaa.php',
    data : dataAnn,
    type :'POST',
    contentType: "application/json; charset=utf-8",
    dataType : 'json',
    success:function(data)
    {
        var response = jQuery.parseJSON(data);
    },
    processData:false
});



}
var mousedown = function(){
        $('div#pop-up').hide();
}




<?
file_put_contents('php://stderr', print_r($_REQUEST, TRUE));
header("Content-Type: application/json"); 
 header("HTTP/1.1 200 OK");
mysql_connect('localhost','root','root');
    mysql_select_db('annotate');
 // if(isset($_POST['data']))   {
    //$data = $_POST['data'];   }


    echo "hello";
    $annstore = mysql_query("INSERT INTO annotator values (".$data.")");
        if($annstore)
    {
        $status = 'Success';
        //$message = 'Successful';
    }
    else
    {
        $status = 'Failure';
        //$message = 'Failed';
    }



    $data = array(
        'status '=>$status,
        //'message'=>$message

        ) 

    echo json_encode($data);

&GT;

0 个答案:

没有答案
相关问题