So, I have a gridbox. If user hits enter, gridbox create a row and load datas inserted by user. Program should run a mysql query with those datas what user insert when he hits enter.
Now I have a html page with a javascriptthat controls the gridbox actions. This js is called when user hits enter:
<script type="text/javascript" >
    var dbs=0;
    var val=[];
    function myFunction(e) {
            if(e.keyCode == 13){
                var newId = (new Date()).valueOf();
                var value=gridbox.cells(1,0).getValue();
                if(value.substring(0,5)=="JrLbl")
                {
//the getfn(value) should returns the value of the mysql query 
                    gridbox.addRow(newId,[value.substring(5,(value.indexOf(".")-4)),getfn(value)]);
                }
                val.push(value);
                gridbox.cells(1,0).setValue('');
                gridbox.editCell(1,0);
                dbs=dbs+1;
            }
    }
    function upload(){
        var jsonString = JSON.stringify(val);
            var jsonData = $.ajax({
                type: "POST",
                  url: "upload.php",
                  data: { 'data' : jsonString},
                  dataType:"json", 
                      async: false
                  }).responseText;
        }
    function getfn(str){
        xmlhttp = new XMLHttpRequest();
        var lblid= str.substring(str.indexOf(".")+6,str.length);
        alert(lblid);
        xmlhttp.open("GET","getfn.php?q="+lblid,true);
        xmlhttp.send();
    }
</script>
And in the getfn.php runs the mysql query:
<?php
header('Content-Type: text/html; charset=UTF-8');
require_once($_SERVER['DOCUMENT_ROOT']."globalfunctions/globalClasses.php");
require_once($_SERVER['DOCUMENT_ROOT'].'globalfunctions/GlobalParameters.php');
error_reporting ( E_ALL ^ E_DEPRECATED);
$q = intval($_GET['q']);
$db_jira = new indotekDbConnection("jira");
            $sql=mysql_query("SELECT FajlNev
                from indoteklabels
                where ID='$q'");
            $FajlNev=mysql_fetch_row($sql);
            return $FajlNev[0];
            $db_jira->Close();
            unset($db_jira);
?>
And it returns the data what should go the marked place

 
     
    