Я хочу загрузить данные из базы данных. «output» должен быть загружен, который содержит некоторые данные о координатах Geofence и добавляется к карте. Здесь нагрузка Функция:Функция загрузки jQuery не работает
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());
}
}
?>
Может кто-нибудь, пожалуйста, скажите мне, где проблема? Мне нужно загрузить вывод на карту.
Эта часть редактируется. Это мои Сохранить функция, которую я хотел запрограммировать функцию нагрузки на его основе:
/* SAVE BUTTON */
jQuery(document).ready(function(){
/*if the submit Button gets clicked this function is called*/
jQuery("#submitButton").click(function() {
/*the text of the html field output and vectorName are stored into javascript variables
vectorOutput
VectorName*/
var vectorOutput = jQuery("#output").val();
var vectorName = jQuery("#vectorName").val();
/*the jQuery.ajax gets openend*/
jQuery.ajax({
/*typ POST gets defined*/
type: "POST",
/*the PHP file that receives the POST*/
url: "parser22.php",
/*the data that gets transfered*/
data: {
/*vector: contains the geometric information of the overlay, in kml format*/
vector: vectorOutput,
/*name: contains the chosen name of the geofence*/
name: vectorName
},
success: function(html){ //so, if data is retrieved, store it in html
/*if the save button gets clicked the field with the geofencename */
jQuery("#output").val('');
/*and kml koordinates get emptied*/
jQuery("#vectorName").val('');
/*to show the user that it worked alert Window pops up*/
alert("Geofence successfully saved!");
}
}); //close jQuery.ajax(
});
// });
Вы уверены, что ваш запрос выбран? – nsthethunderbolt
** Должен быть загружен «вывод», который содержит некоторые данные о координатах Geofence и добавляется к карте **. Что это значит? ** «поэтому, если данные извлекаются, храните их в html» ** И НЕ НИЧЕГО С НИМ. – PeterKA
Я не уверен, что я просто подумал, что SELECT FROM может работать. У вас есть идея? – user3834704