+Функция postJsonData
This commit is contained in:
@ -534,7 +534,11 @@
|
|||||||
try
|
try
|
||||||
{ $res = $stmt->execute();
|
{ $res = $stmt->execute();
|
||||||
} catch (Exception $e)
|
} catch (Exception $e)
|
||||||
{ sendError(1,$e->getMessage()."\n".$sql_query);
|
{
|
||||||
|
if(str_contains($e->getMessage(), ']]')) //If already sending short error text.
|
||||||
|
sendError(1, $e->getMessage());
|
||||||
|
else
|
||||||
|
sendError(1, '[['.trt("SQL_query_error").']]'.$e->getMessage()."\n".$sql_query);
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_NUM); //$obj_id
|
$result = $stmt->fetch(PDO::FETCH_NUM); //$obj_id
|
||||||
if($result[0]==''){ $result[0]=$obj_id; }
|
if($result[0]==''){ $result[0]=$obj_id; }
|
||||||
@ -569,7 +573,11 @@
|
|||||||
try
|
try
|
||||||
{ $res = $db->query($sql_query);
|
{ $res = $db->query($sql_query);
|
||||||
}catch (Exception $e)
|
}catch (Exception $e)
|
||||||
{ sendError(1,$e->getMessage());
|
{
|
||||||
|
if(str_contains($e->getMessage(), ']]')) //If already sending short error text.
|
||||||
|
sendError(1, $e->getMessage());
|
||||||
|
else
|
||||||
|
sendError(1, '[['.trt("SQL_query_error").']]'.$e->getMessage()."\n".$sql_query);
|
||||||
}
|
}
|
||||||
//записываем id удалённой записи для удаления без перезагрузки страницы через javascript
|
//записываем id удалённой записи для удаления без перезагрузки страницы через javascript
|
||||||
$xmlstring="";
|
$xmlstring="";
|
||||||
@ -1290,9 +1298,7 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
$file='file_'.$num.'.xls';
|
$file='file_'.$num.'.xls';
|
||||||
$myFile = $dir.$file;
|
$myFile = $dir.$file;
|
||||||
|
|
||||||
$fh = fopen($myFile, 'w');
|
if(($fh = @fopen($myFile, 'w')) !== FALSE){
|
||||||
if($fh)
|
|
||||||
{
|
|
||||||
fwrite($fh, '<html>'."\n");
|
fwrite($fh, '<html>'."\n");
|
||||||
fwrite($fh, ' <head>'."\n");
|
fwrite($fh, ' <head>'."\n");
|
||||||
fwrite($fh, ' <title>'.$currNode->getAttribute("d").'</title>'."\n");
|
fwrite($fh, ' <title>'.$currNode->getAttribute("d").'</title>'."\n");
|
||||||
@ -1345,7 +1351,9 @@ if ($code!=$_POST['code']) return new AuthError('invalid code');
|
|||||||
fwrite($fh, '</html>'."\n");
|
fwrite($fh, '</html>'."\n");
|
||||||
|
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
}
|
}else{
|
||||||
|
sendError(1,trt('Failed_to_generate_report'));
|
||||||
|
}
|
||||||
|
|
||||||
/*if($ext=="pdf")
|
/*if($ext=="pdf")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1472,7 +1472,7 @@ class SRec
|
|||||||
{
|
{
|
||||||
if(nodeCol.nodeName=="column")
|
if(nodeCol.nodeName=="column")
|
||||||
{
|
{
|
||||||
if(nodeCol.getAttribute("n")==col){
|
if(nodeCol.getAttribute("n")==name){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@ -20,6 +20,18 @@ function trt(key)
|
|||||||
else return val;
|
else return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteOption(sel,id){
|
||||||
|
if(typeof sel == 'string') sel=document.getElementById(sel);
|
||||||
|
let i=0;
|
||||||
|
while (i<sel.length) {
|
||||||
|
if(sel.options[i].value == id) {
|
||||||
|
sel.remove(i);
|
||||||
|
}else{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Расширить плитку чтобы она занимала всю штртну области
|
//Расширить плитку чтобы она занимала всю штртну области
|
||||||
//margin - С права и слева по одному пикселю (умножается на 2)
|
//margin - С права и слева по одному пикселю (умножается на 2)
|
||||||
function resizeDivTile(parent,minWidth)
|
function resizeDivTile(parent,minWidth)
|
||||||
@ -168,7 +180,6 @@ function hideProgressBarIco()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//var eDiv=document.getElementById('eDiv'+this.uid);
|
|
||||||
function loadContent(url,obj)
|
function loadContent(url,obj)
|
||||||
{
|
{
|
||||||
if (typeof obj === 'string' || obj instanceof String)
|
if (typeof obj === 'string' || obj instanceof String)
|
||||||
@ -190,6 +201,37 @@ function loadContent(url,obj)
|
|||||||
req.send( null );
|
req.send( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//POST Json Data to server and Json in result
|
||||||
|
function postJsonData(url,data,fun){
|
||||||
|
if(typeof data !== 'string') {
|
||||||
|
data = JSON.stringify(data);
|
||||||
|
}
|
||||||
|
let req=createRequestObject();
|
||||||
|
req.onreadystatechange = function(req)
|
||||||
|
{
|
||||||
|
return function(){
|
||||||
|
if(req.readyState == 4 || typeof(req.readyState)=='undefined'){
|
||||||
|
if(req.status == 200) {
|
||||||
|
let json = null;
|
||||||
|
try {
|
||||||
|
json = JSON.parse(req.responseText);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
if (json != null)
|
||||||
|
fun(true, json);
|
||||||
|
else
|
||||||
|
fun(false, req.responseText);
|
||||||
|
}else{
|
||||||
|
fun(false,trt('Failed_to_receive_data'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}(req);
|
||||||
|
req.open( "POST", url, true );
|
||||||
|
req.setRequestHeader("Content-type", "application/json");
|
||||||
|
req.send(data);
|
||||||
|
}
|
||||||
|
|
||||||
//Вывести текст поверх окон с кнопочкой OK
|
//Вывести текст поверх окон с кнопочкой OK
|
||||||
function alert2(title,smallText,fullText,okFunc=null)
|
function alert2(title,smallText,fullText,okFunc=null)
|
||||||
{
|
{
|
||||||
@ -773,6 +815,7 @@ function createRequestObject()
|
|||||||
}
|
}
|
||||||
return new XMLHttpRequest();
|
return new XMLHttpRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
//создать DOMParser
|
//создать DOMParser
|
||||||
function CreateXMLDOC(xmlString)
|
function CreateXMLDOC(xmlString)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user