1
Hello fellow developer!
I'm working on a new module (quiet calm are just the beginning) but I need a hand.
In Admin Side,i'm doing a form that inserts a field in a table and I'm doing with jQuery, and now it works. Unfortunately, if active XOOPS debugging the ajax does not work anymore.
This is the code of the page format.php
<?php include 'header.php'; if(isset($_GET['delete'])) { $sql = 'DELETE FROM '.$xoopsDB->prefix('umus_format').' WHERE format_id = '.(int)$_GET['delete']; $result = $xoopsDB->queryF($sql); if(isset($_GET['ajax'])&&$_GET['ajax']==1) exit(); } if ($_REQUEST[fname] != ""){ $fname = htmlspecialchars(trim($_REQUEST['fname'])); $sql_insert = "INSERT INTO ".$xoopsDB->prefix("umus_format")."(format_title) VALUES ('".$fname."')"; $result_insert = $xoopsDB->queryF($sql_insert); $fid = $xoopsDB->getInsertId(); echo $fid; exit(); } xoops_cp_header(); loadModuleAdminMenu(1, ""); //includo js e css include ('../include/library.php'); //per tutti i casi abilito il textsanitizer $myts =& MyTextSanitizer::getInstance(); if (isset($_GET)) { foreach ($_GET as $k => $v) { if(!isset($$k)) $$k = $v; } } if (isset($_POST)) { foreach ($_POST as $k => $v) { if(!isset($$k)) $$k = $v; } } ?> <form id="submit" method="post"> <fieldset style='height:45px;'> <legend>Inserisci nuovo formato</legend> <label for="fname">Formato:</label> <input id="fname" class="text" name="fname" size="20" type="text" /><div class='success'>Formato inserito con successo.</div> <button class="button positive">Aggiungi</button> </fieldset> </form> <?php echo "<table class='stripeMe' id='tablist'> <th colspan='4'>"._MI_UMUS_LISTFORMAT."</th> <tr class='head'><td>"._MI_UMUS_FORMAT_TITLE."</td><td width='150'>"._MI_UMUS_ACTION."</td></tr>"; $sql = 'SELECT * FROM '.$xoopsDB->prefix('umus_format').' ORDER BY format_title '; $result = $xoopsDB->queryF($sql); while($row = mysql_fetch_array($result)) { echo '<tr class="record" id="record-',$row['format_id'],'"> <td><strong>'.$row['format_title'].'</strong></td> <td text-align="center"><a href="?delete='.$row['format_id'].'" class="delete" ><img src="../images/del.png" alt="'._MI_UMUS_DELETE.'" /></a> </td> </tr>'; } echo "</table>"; xoops_cp_footer(); ?>
library.php
le="color: #000000"><?php <link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="../css/umusic.css" /> <script type="text/javascript" src="../library/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="../library/jquery.confirm.js"></script> <script type="text/javascript" src="../library/jquery.mie.js"></script> <script type="text/javascript" src="../library/jquery.color.js"></script>
jquery.mie.js (my script)
le="color: #000000"><?php //cancello un formato $(document).ready(function() { $('a.delete').click(function(e) { e.preventDefault(); //var parent = $(this).parent(); var parent = $(this).parent("td").parent("tr"); { $.ajax({ type: 'get', url: 'format.php', data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''), success: function() { parent.fadeOut(500,function() { parent.remove(); }); } }); } }).confirm(); }); //stripe table $(document).ready(function(){ $('.stripeMe tr').mouseover(function(){ $(this).addClass("over"); }); $('.stripeMe tr').mouseout(function(){ $(this).removeClass("over"); }); $('.stripeMe tr:even').addClass('alt'); }); //creo un nuovo formato $(document).ready(function(){ $('form#submit').submit(function() { // we want to store the values from the form input box, then send via ajax below var fname = $('#fname').attr('value'); if (fname != "") { $.ajax({ type: 'post', dataType: 'text', url: 'format.php', data: 'fname='+ fname, success: function(fid){ $('div.success').fadeIn(1000); $('div.success').fadeOut(3000); $('table#tablist').append("<tr class='record' id='record-"+fid+"' style='background-color:#ff6666; color:#ffffff;'><td><strong>"+fname+"</strong></td><td text-align='center'><a href='?delete="+fid+"' class='delete'><img src='../images/del.png' alt='Delete' /></a></td></tr>"); $('a.delete').click(function(e) { e.preventDefault(); //var parent = $(this).parent(); var parent = $(this).parent("td").parent("tr"); { $.ajax({ type: 'get', url: 'format.php', data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''), success: function() { parent.fadeOut(500,function() { parent.remove(); }); } }); } }).confirm(); } }); } return false; }); });