jQWidgets Forums

jQuery UI Widgets Forums Editors Button, RepeatButton, ToggleButton, LinkButton sending data via ajax on click of button

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 10 years ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • claudegel
    Participant

    I’ve a script that is using a grid to send data to mysql via php. in that script I’ve set 2 button to close the page or reload it with resetted data like this:

    $("#Button5").jqxLinkButton({ width: '80', height: '20', theme: 'classic'});
     $("#Button6").jqxLinkButton({ width: '80', height: '20', theme: 'classic'});
    

    on clicking any of these button I want to send data via ajax to another mysql table like this:

    $('#Button5').on('click', function () {
    					close_form(form_no);
                	});
    
            	$('#Button6').on('click', function () {
    				close_form(form_no);
            	});
            	
            	function close_form(form_no)
                {
            		var registre = "<a href='show.php?form_no=" + form_no +"' target='retour'></a>";
            		var data = "insert=true&dbase=formadmin&date_actif=" + ladate + "&ficheno=169&delais=1&date_retourne=" + ladate + "&complet=1&conforme=0&resp=9&source=0&lien=0&qtt_ncr=0&registre=" + registre;
            		
            		$.ajax({
                          dataType: 'json',
                          url: '../moteur/index.php',
                          type:	"POST",
                          data: data,
            		      cache: false,
            		      success: function(data){
    							alert(data);
            		      },
            		      error: function(){
                		      alert("marche pas");
            		      }
                        });
                }
    

    my script work perfectly but when I click any of the two button nothing is sent to mysql. I’m sending data via the same php engine that I use througout the script.

    What’s wrong


    claudegel
    Participant

    forget to say the two button are set like this:

    finish
    next

    the two button are loading the correct pages but data is not sent


    claudegel
    Participant

    sorry better like this

    <a style='margin: 5px;' target="_self" href="../menu.php" id='Button5'>finish</a>
    <a style='margin: 5px;' target="_self" href="./index.php" id='Button6'>next</a>
    

    Dimitar
    Participant

    Hello claudegel,

    We suggest you use a jqxButton instead of a jqxLinkButton and navigate to the target pages after the Ajax request has been completed (in the success callback). Initialize the jqxButtons from input (type="text") or button tags.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    claudegel
    Participant

    Thanks it work perfectly

    $('#Button5').on('click', function () {
    					close_form(form_no,"../menu.php");
                	});
    
            	$('#Button6').on('click', function () {
    				close_form(form_no,"./index.php");
            	});
            	
            	function close_form(form_no,adress)
                {
            		var registre = "<a href=\"show.php?form_no=" + form_no +"\" target=\"retour\"></a>";
            		var data = "insert=true&dbase=formadmin&date_actif=" + ladate + "&ficheno=169&delais=1&date_retourne=" + ladate + "&complet=1&conforme=0&resp=9&source=0&lien=0&qtt_ncr=0&registre=" + registre;
            		
            		$.ajax({
                          dataType: 'json',
                          url: '../moteur/index.php',
                          type:	"POST",
                          data: data,
            		      cache: false,
            		      success: function(data){
    							//alert(data);
            		    	  window.location.href = adress;
            		      },
            		      error: function(){
                		      alert("no way");
            		      }
                        });
                }
    

    database is updated and page is redirected as needed

    How do I adjust the button text as now the text is not perfectly centered. I want my button to have the same look as the first two button below

    <div>
    <input id="addrowbutton" type="button" value="Ajouter" />
    			<input id="deleterowbutton" type="button" value="Effacer" />
    			<input type="button" value="Terminé" id='Button5' />
    			<input type="button" value="Suivant" id='Button6' />
    </div>

    In the last two button the text is not centered vertically. Also the two last button are not alligned on the same line as the first two. They are a little higher on the line.


    Dimitar
    Participant

    Hello claudegel,

    Your HTML seems correct. Here is an example with four jqxButtons initialized from it: http://jsfiddle.net/Dimitar_jQWidgets/gf0e0w30/. Maybe there is something in your JavaScript that causes the issue.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.