Display a modal pop up after insert, update and delete

Hello one and all,
I have a problem with dataprocessor, in fact, I want to display a modal pop up after my insert, update and delete opérations. But I don’t know how , I used onafterupdate like this:

if(name=="nouveau")
						 {
							{
								dhxWins = new dhtmlXWindows();
								modalNewAnnee = dhxWins.createWindow(1, 550, 250, 450, 350);
								modalNewAnnee.setText("Modification année budgétaire");
								formannee = modalNewAnnee.attachForm(structformannee);
								var dpp = new dataProcessor("controleurs/annee.php");
								dpp.init(formannee);	
								// ceci est l\évènement qui agit sur le bouton engistrer du formulaire année
								formannee.attachEvent("onButtonClick", function(name, command)
									{
										if(name=="enregistrer")
										{
											formannee.save();
											modalNewAnnee.close();
											dpp.attachEvent("onAfterUpdateFinish",function(){
										   alert("Opération réalisée avec succès");
											});
										}										
										/**/
									}
								);
							}
						 }

I summarize the problème:
I want to display a pop up with the message “Operation completed successfully” or “impossible éffectuer operation” after the insert, update and delete opérations.

can someone please help me??

onAfterUpdateFinish doesn’t have info about results of data saving, you can use onAfterUpdate instead

dpp.attachEvent("onAfterUpdate",function(sid, action, tid){ if (action == "error" || action == "invalid") show_popup("error_message"); else show_popup("valid_message"); });

thank you Stanislav for your time,
I do this

if(name=="nouveau")
						 {
							{
								dhxWins = new dhtmlXWindows();
								modalNewAnnee = dhxWins.createWindow(1, 550, 250, 450, 350);
								modalNewAnnee.setText("Modification année budgétaire");
								formannee = modalNewAnnee.attachForm(structformannee);
								var dpp = new dataProcessor("controleurs/annee.php");
								dpp.init(formannee);	
								// ceci est l\évènement qui agit sur le bouton engistrer du formulaire année
								formannee.attachEvent("onButtonClick", function(name, command)
									{
										if(name=="enregistrer")
										{
											formannee.save();
											modalNewAnnee.close();
											dpp.attachEvent("onAfterUpdate",function(sid, action, tid){
											 if (action == "error" || action == "invalid")
												   alert("Impossible de réaliser cette opération, veuillez consulter le fichier log pour plus informations");
											 else
												   alert(" Opération réalisée avec succès ");
											});
										}										
										/**/
									}
								);
							}
						 }

but no pop up does not appear after inserting data

a) try to move attachEvent at least before form.save() call, as in some cases browser can process it in sync mode. ( specific of IE )

b) do you have any kind of validation assigned to form ? If validation fails, data saving will be blocked.

I have no validation on my form
my operation is realized normally, but I want to display a pop up after each operation.

but the pop up does not appear .

The similar code works correctly locally :frowning:
Please PM if you have the online demo of the problem.

In fact, I still work locally, I send you my script on the server side, may be, there is a problem.
Here is my server side script:

<?php
try {			
		require_once 'config_db.php';
		if ($gridConn->is_select_mode())
		{			
			$gridConn->render_complex_sql("SELECT * FROM fj_findall_annee()","id","nom,iscurrent,islocked,debut,fin");
		}else
		{ 
			$nom=$_POST[$_POST["ids"]."_nom"];
			$debut=$_POST[$_POST["ids"]."_debut"];
			$fin=$_POST[$_POST["ids"]."_fin"];
			$idcache=$_POST[$_POST["ids"]."_idcache"];
			
			$db->query("SELECT fj_save_annee($idcache,'$nom','$debut','$fin')");			
		}
		
    }
	catch (PDOException $e)
	{
		print "Erreur sql !: " . $e->getMessage() . "<br/>";
		die();
    }

Merci de m’apporter un peu de soutient.

In fact, I still work locally, I send you my script on the server side, may be, there is a problem.
Here is my server side script:

    <?php
    try {         
          require_once 'config_db.php';
          if ($gridConn->is_select_mode())
          {         
             $gridConn->render_complex_sql("SELECT * FROM fj_findall_annee()","id","nom,iscurrent,islocked,debut,fin");
          }else
          {
             $nom=$_POST[$_POST["ids"]."_nom"];
             $debut=$_POST[$_POST["ids"]."_debut"];
             $fin=$_POST[$_POST["ids"]."_fin"];
             $idcache=$_POST[$_POST["ids"]."_idcache"];
             
             $db->query("SELECT fj_save_annee($idcache,'$nom','$debut','$fin')");         
          }
          
        }
       catch (PDOException $e)
       {
          print "Erreur sql !: " . $e->getMessage() . "<br/>";
          die();
        }

Thank you for bringing me a little support

Yep, there is
In case of data saving server side must return valid xml response, it seems that your code returns nothing.

Something like next

$db->query("..."); header("Content-type:text/xml"); echo "<data><action type='update' sid='$id' tid='$id'></data>";

where $id = $_POST[“ids”]; for the single row update case.

Thank you for your availability Stanislav,

I’ll try and give you the report.

i change it like this:

$db->query("SELECT fj_save_annee($idcache,'$nom','$debut','$fin')");
			header("Content-type:text/xml");
			echo "<data><action type='update' sid='".$id."' tid='".$id."'></data>";

and i get this on response:

<data><action type='update' sid='1365416113264' tid='1365416113264'></data>

this on xml:

Erreur d'analyse XML : balise ne correspondant pas. Attendu : </action>. Emplacement : moz-nullprincipal:{d55ead71-852c-4d0f-91f1-a3a19036bd5c} Numéro de ligne 1, Colonne 71 :

...pdate' sid='1365416113264' tid='1365416113264'></data>
...-------------------------------------------------^

But the operation went well, the data are saved correctely.

Please! I summarized my problem:

I want to return a message in server side and in client side display this message in a pop up.
all this after the update operation, deleting and adding.

Sorry was my typo, you need to have

<data><action type='update' sid='$id' tid='$id' /></data> 

There is a closing “/” at end of action tag, which was missed
As for custom message, you can use the same code but extend it a bit

<data><action type='update' sid='$id' tid='$id' /><![CDATA[ $message ]]></data> 

Now on client side you can use

dp.attachEvent("onAfterUpdate", function(sid,action,tid, tag){
     var message = tag.firstChild?tag.firstChild.nodeValue:"";
     if (message)
         alert(message);
}

tag - represents the action tag from response, so you can send custom data from server side by using its value or attributes, which will later be fetched in onAfterUpdate event

thank you,
but so far the update is in the database, but no pop up does not appear
I’m desperate, I did this in the server :

global $gridConn, $db;
	 //$gridConn->enable_log("temp.log",true);
     //LogMaster::log("Une erreur critique est survenue lors du traitement");
	$db->query("SELECT fj_save_annee(".$this->id.",'".$this->nom."','".$this->debut."','".$this->fin."');");
	$message = "opération réalisée avec succès";
	//echo "Enregistrement éffectué avec sussès";
	header("Content-type:text/xml");
	echo "<data><action type='update' sid='$this->id' tid='$this->id' /><![CDATA[ $message ]]></data>";

this in client side

dp.attachEvent(“onAfterUpdate”, function(sid,action,tid, tag){
var message = tag.firstChild?tag.firstChild.nodeValue:"";
if (message)
alert(message);
});

this on response:

<data><action type='update' sid='231' tid='231' /><![CDATA[ opération réalisée avec succès ]]></data>

this  on xml :

<data>
<action type="update" sid="231" tid="231"></action>
opération réalisée avec succès
</data>

which seems correct at the server side, but at the client side, not pop up appears

can i use send() method instead of save ()

ah! excuse me please!
it works well to insert and modify, but delete does not work.

in response i have this

<data><action type='delete' sid='243' tid='243' /><![CDATA[ opération réalisée avec succès ]]></data>

in xml i have this:

<data>
<action type="delete" sid="243" tid="243"></action>
opération réalisée avec succès
</data>

and pop up does not appear

Try to change the format of response to

so the message will be wrapped by action tag.

thank you,
it does not always work, I wanted to know if there is another way to retrieve the response when deleting.

in insertion or update, I do a save () and , in delete I do not know how to delete in data base and send response to the client.

thank you for your available.

In paramètre, i have this:

editing	true

this in post :

1365785298498_!nativeedit...	inserted
1365785298498_idsupprimer	260
ids	1365785298498

in response :

1<data><action type='update' sid='260' tid='260' /><![CDATA[opération réalisée avec succès]]></action></data>

in xml:

Erreur d'analyse XML : mal formé Emplacement : moz-nullprincipal:{dcee8080-0577-4a14-81d5-c8575fde1ddd} Numéro de ligne 1, Colonne 2 :

1<data><action type='update' sid='260' tid='260' /><![CDATA[opération réalisée a...
-^

il my firebug console

According to the log you have

<data><action type='update' sid='260' tid='260' /><![CDATA[opération réalisée avec succès]]></action></data>

But, to be a valid xml, it must be

<data><action type='update' sid='260' tid='260'><![CDATA[opération réalisée avec succès]]></action></data>

closing bracket of action tag has extra / char in your case.