Javascript jQuery加载函数不工作

Javascript jQuery加载函数不工作,javascript,jquery,load,Javascript,Jquery,Load,我想从数据库加载数据。必须加载输出,其中包含一些关于地理围栏坐标的数据,并将其添加到地图中。以下是加载函数: jQuery("#submitButtonLoad").click(function () { /*the jQuery.ajax gets openend*/ jQuery.ajax({ /*typ POST gets defined*/

我想从数据库加载数据。必须加载输出,其中包含一些关于地理围栏坐标的数据,并将其添加到地图中。以下是加载函数:

           jQuery("#submitButtonLoad").click(function () {

                /*the jQuery.ajax gets openend*/
                jQuery.ajax({
                    /*typ POST gets defined*/
                    type: "POST",
                    /*the PHP file that receives the POST*/
                    url: "parsernew.php",
                    /*the data that gets transfered*/


                    success: function(html){ //so, if data is retrieved, store it in html

                    var vectorOutput = jQuery("#output").val();
                    var vectorName = jQuery("#vectorName").val();

                    jQuert('#output').html();

                    }
                }); //close jQuery.ajax(
            });
这也是parsernew.php,它从数据库获取所需的数据。通过使用config.php完成连接:

 <?php    
 session_start();    
 print_r($_SESSION);    

 /*if the id parameter is not set an error occures*/     
 if (!isset($_SESSION['id'])) {      
 /*ajax request/abfrage, check.....*/      
 echo 'the user id is missing';     
 die();     
 }     
 /*if the id parameter is set else gets executed*/     
 else     
 {     
 /*the id of the user gets requested*/     
 $id=$_SESSION['id'];     
 /*the parameters get requested and saved into local variables*/     
 $vector      = ($_POST['vector']);     
 $name        = ($_POST['name']);     
 echo $id;     
 echo $vector;     
 echo $geofence;     
 /*the config.in.php is called*/     
 /*this programms opens the conncetion to the database*/     
 include('config.php');       
 /*the SELECT query gets created*/      
 $eintrag = "SELECT (geofencename,geometry,fk_user_geofence) VALUES ('$name','$vector','$id') FROM public.geofence";      

/*the above mentioned query gets executed      
--> this always executes a query, no matter what kind */      
$eintragen = pg_query($eintrag);     

/*if the query is not correct an error occures*/     
 if (!$eintrag) {      
        die("Error in SQL query: " . pg_last_error());       
  }          
 }      
?>      

执行查询的数据库用户是否具有适当的读取权限?另外,我假设以下内容仅在这里是一个输入错误,而不是在您的运行代码中

jQuert('#output').html();
编辑1:

很难准确地理解你想要达到的目标。顺便说一句,它更灵活,更喜欢用“完成”而不是“成功”来做这样的事情:

  jQuery.ajax({
       // config
  }).done(function(data){
       // do something with data
       jQuery('#output').html(data);
  });
编辑2:

查看下面评论中的示例CRUD链接,加载与保存操作的布局结构基本上就是我从您试图实现的内容中推断出来的。post方法只是一种更具体的方法,因此如果需要,可以用ajax替换它。试着在代码中尽可能多地遵循“不要重复自己”的原则。在这种情况下,可以先使用公共加载方法,然后再调用save方法。

成功中的代码毫无意义。即使会,也有一个输入错误:jQuert。我想你想要的是:

success: function(html){
            var foo = doSomething(html);
            jQuery('#output').html(foo);
         }

您确定您的select查询正在运行吗?必须加载输出,其中包含一些关于Geofiness坐标的数据,并将其添加到地图中。这是什么意思?所以,如果检索到数据,请将其存储在html中,不要对其进行任何操作。我不确定我只是认为SELECT FROM可能会起作用。你有更好的主意吗?这句话毫无意义。这就是我要说的;也许只有我一个人。有可能我们在地图上画多边形的形状。这些数据保存在输出中,并保存在数据库中。现在我想加载它们,当用户刷新页面时,他可以通过点击加载按钮获得他之前绘制的形状。我刚刚编辑了我的问题并添加了保存功能。你能不能根据这一点更准确地指导我,什么应该是成功的:功能?不,对不起,我不明白你想做什么。显然,您希望以某种方式使用接收到的html,但现在您只清除了一些字段。那么,如何根据我的保存功能加载输出?您希望将内容放入输出?这些内容是从数据库接收到的数据吗?在这个项目中,我们可以在地图上绘制多边形形状。这些绘制的形状是数据,保存在输出中,并通过单击“保存”按钮保存在数据库中。现在我想加载它们,当用户刷新页面时,他可以通过单击加载按钮在地图上绘制上一个形状。那么成功应该是什么:函数而不是那个?我已经编辑了我的问题并添加了保存功能。我想在save函数的基础上创建load函数,这有什么帮助吗;jquerytoutput.htmlvectorOutput;正如你所说,我改变了一切。但不幸的是,它不起作用。也许这会有所帮助
success: function(html){
            var foo = doSomething(html);
            jQuery('#output').html(foo);
         }