send extra data value with php/jquery UI to ajax.php file

jamesthomas_1

New Member
i try to send a extra $php_var with jQuery true an ajax post function.in the 1st $.ajax i have\[code\] $('.ui-icon-closethick').click(function(e) { e.preventDefault(); var parent = $(this).parent().parent(); $.ajax({ type: "POST", url: "server_items_reorder.php", data: 'id=' + parent.attr('id'), success: function() { parent.slideUp(300,function() { parent.remove(); }); } });});\[/code\]the data: 'id=' + parent.attr('id') needs a extra $php_var sended to the url: "server_items_reorder.php"a little further down in my code i have:\[code\] function savelayout(){var positions = "";var weight = 0;var wb_name = "$wb_name";$(".portlet").each(function(){weight++;positions+=(this.id + "=" + this.parentNode.id + "|" + weight + "&");});$.ajax({type: "POST",url: "server_items_reorder.php",data: positions});} \[/code\]as you can see i already treid there to add a $var called wb_name.Full code here:\[code\] sql_fetchrow($db->sql_query('SELECT radminsuper FROM ' . $prefix . '_authors WHERE aid=\'' . $aid . '\''));if ($row['radminsuper'] == 1) {/*********************************************************//* Blocks_Manager Functions *//*********************************************************/function BlocksManager($wb_name) { global $db, $prefix, $currentlang, $multilingual, $bgcolor2, $admin_file; OpenHeader(_BLOCKMGR); $wb_url="".$admin_file.".php?op=BlocksManager&wb_name="; echo "\n" ._BLOCKMGR_MODULEDROP." \n"; if (!isset($wb_name)) { $wb_name = "admin"; } echo "Admin\n"; $result = $db->sql_query("SELECT mid, title, custom_title, active, view, inmenu FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC"); while(list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) { echo "$custom_title\n"; if (!isset($wb_name)) { $wb_name = $title; } } echo "\n" ."\n\n"; echo "

"; echo ""._BLOCKMGR_ADDNEWBLOCK."\n" ."\n" ."\n" ."\n"; //List all inactive Blocks for selected module echo "\n" ._BLOCKMGR_ACTIVE_BLOCKS."
\n" ."\n"; $sql = "SELECT bid, title FROM ".$prefix."_blocks ORDER BY title ASC"; $result = $db->sql_query($sql); while (list($bid, $title) = $db->sql_fetchrow($result)) { $ii = 0; $wb_affiche = 1; while ($ii $title\n"; } } echo "
\n" ."\n" ."\n"; //List all active Modules echo "" .""._BLOCKMGR_MODULES."
\n"; echo "Admin\n"; $sql = "SELECT mid, title, custom_title FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC"; $result = $db->sql_query($sql); while(list($mid, $title, $custom_title) = $db->sql_fetchrow($result)) { echo "$custom_title\n"; if (!isset($wb_name)) { $wb_name = $title; } } echo "
" ."\n"; //List all active Blocks for selected module echo "\n" ._BLOCKMGR_INACTIVE_BLOCKS."
\n" ."\n"; $sql = "SELECT b.bid, b.title FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY title ASC"; $result = $db->sql_query($sql); while(list($bid, $title) = $db->sql_fetchrow($result)) { echo "$title\n"; } echo "
\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n";?> body { font-size: 62.5%; } label, input { display:block; } input.text { margin-bottom:12px; width:95%; padding: .4em; } fieldset { padding:0; border:0; margin-top:25px; } h1 { font-size: 1.2em; margin: .6em 0; } div#users-contain { width: 350px; margin: 20px 0; } div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; } div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; } .ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none; !important; cursor:pointer; position: relative; text-align: center; } .ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em; } .column { width: 170px; float: left; padding-bottom: 100px; } .portlet { margin: 0 1em 1em 0; } .portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; } .portlet-header .ui-icon { float: right; } .portlet-content { padding: 0.4em; } .ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; } .ui-sortable-placeholder * { visibility: hidden; } $(function() { $(".column").sortable({ connectWith: '.column', update: savelayout }); $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all delete") .find(".portlet-header") .addClass("ui-widget-header ui-corner-all") .prepend('') .prepend('') .prepend('') .end() .find(".portlet-content").toggle(); $(".portlet-header .ui-icon-plusthick").toggle(function() { $(this).removeClass("ui-icon-plusthick"); $(this).addClass("ui-icon-minusthick"); $(this).parents(".portlet:first").find(".portlet-content").toggle(); }, function() { $(this).removeClass("ui-icon-minusthick"); $(this).addClass("ui-icon-plusthick"); $(this).parents(".portlet:first").find(".portlet-content").toggle(); } ); $('.ui-icon-closethick').click(function(e) { e.preventDefault(); var parent = $(this).parent().parent(); $.ajax({ type: "POST", url: "server_items_reorder.php", data: 'id=' + parent.attr('id'), success: function() { parent.slideUp(300,function() { parent.remove(); }); } }); }); $(".column").disableSelection(); }); 1455064430-1273457753-827849677-2124940291842838179 $tValue) { $sql = "SELECT MAX(weight) FROM ".$prefix."_blocks_manager WHERE title='$tValue'"; $result = $db->sql_query($sql); list($weight, $bposition) = $db->sql_fetchrow($result); foreach($bid as $bKey => $bValue) { $weight++; $db->sql_query("INSERT INTO ".$prefix."_blocks_manager VALUES ($bValue, '$tValue', 'l', $weight)"); } BlocksManager_FixWeight($tValue); }}function BlocksManager_Remove($bid, $title) { global $db, $prefix; foreach($title as $tKey => $tValue) { foreach($bid as $bKey => $bValue) { $db->sql_query("DELETE FROM ".$prefix."_blocks_manager WHERE bid='$bValue' AND title='$tValue'"); } BlocksManager_FixWeight($tValue); }}function BlocksManager_FixWeight($wb_name) { global $db, $prefix; $position[] = 'l'; $position[] = 'r'; $position[] = 'c'; $position[] = 'd'; $position[] = ''; foreach($position as $pKey => $pValue) { $result = $db->sql_query("SELECT bid FROM ".$prefix."_blocks_manager WHERE title='$wb_name' AND bposition='$pValue' ORDER BY weight ASC"); $weight = 0; while(list($bid) = $db->sql_fetchrow($result)) { $weight++; if ($pValue != '') : $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight' WHERE title='$wb_name' AND bid='$bid'"); else : $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight', bposition='l' WHERE title='$wb_name' AND bid='$bid'
"); endif; } }}function BlocksManager_BlockPosition($bid, $wb_name, $position) { global $db, $prefix; $db->sql_query("UPDATE ".$prefix."_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$wb_name'"); BlocksManager_FixWeight($wb_name);}function BlocksManager_BlockOrder($wb_name, $weightrep, $weight, $bidrep, $bidori) { global $db, $prefix; $result = $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight' WHERE bid='$bidrep'"); $result2 = $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weightrep' WHERE bid='$bidori'"); BlocksManager_FixWeight($wb_name);}function OpenHeader($title="") { include("header.php"); GraphicAdmin(); title($title); OpenTable();}function CloseFooter() { CloseTable(); include("footer.php");}switch($op) { case "BlocksManager": BlocksManager($wb_name); break; case "BlocksManager_Add": BlocksManager_Add($bida, $title); Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name"); break; case "BlocksManager_Remove": BlocksManager_Remove($bidr, $title); Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name"); break; case "BlocksManager_BlockPosition": BlocksManager_BlockPosition($bid, $title, $position); Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$title"); break; case "BlocksManager_FixWeight": BlocksManager_FixWeight($wb_name); Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name"); break; case "BlocksManager_BlockOrder": BlocksManager_BlockOrder ($title, $weightrep, $weight, $bidrep, $bidori); Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$title"); break; }} else { echo "Access Denied";}?> \[/code\]The purpose of the code is to control a block system by modules , you can move/add/change/delete blocks by it's module
 
Back
Top