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
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;
}
}
?>
echo "
"._MI_UMUS_LISTFORMAT." |
"._MI_UMUS_FORMAT_TITLE." | "._MI_UMUS_ACTION." |
";
$sql = 'SELECT * FROM '.$xoopsDB->prefix('umus_format').' ORDER BY format_title ';
$result = $xoopsDB->queryF($sql);
while($row = mysql_fetch_array($result))
{
echo ',$row['format_id'],'">
'.$row['format_title'].' |
.$row['format_id'].'" class="delete" >._MI_UMUS_DELETE.'" /> |
';
}
echo "
";
xoops_cp_footer();
?>
library.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)
//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("+fid+"' style='background-color:#ff6666; color:#ffffff;'>"+fname+" | +fid+"' class='delete'> |
");
$('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;
});
});