Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在同一页面上将javascript变量从modal传递到php_Javascript_Php_Jquery - Fatal编程技术网

在同一页面上将javascript变量从modal传递到php

在同一页面上将javascript变量从modal传递到php,javascript,php,jquery,Javascript,Php,Jquery,事实上,我一天都在纠结这个问题。我只想对这个脚本执行编辑操作。我的主页名是customer-grid-screen.php 代码如下 <?php include("header.inc.php"); include("left.inc.php"); include('config.php');?> <div id="page-content-wrapper"> <?php include("pagetitile.inc.php"); ?> <d

事实上,我一天都在纠结这个问题。我只想对这个脚本执行编辑操作。我的主页名是customer-grid-screen.php 代码如下

<?php include("header.inc.php");
include("left.inc.php");
include('config.php');?>

<div id="page-content-wrapper">
  <?php include("pagetitile.inc.php"); ?>
  <div id="page-content">
  <div class="clearfix mrg10B"><a href="javascript:;"   class="btn large bg-green float-right modal-customeradd" title=""><span class="button-content">Add</span></a></div>
<div class="example-box">
    <div class="example-code">

        <table class="table table-condensed">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Details</th>
                    <th>Domain</th>
                    <th>Vertical</th>
                    <th>Taxanomy</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>

<?php
$result = mysql_query("SELECT * FROM customer_mast ORDER BY customer_id") or trigger_error(mysql_error());

while($row = mysql_fetch_array($result)){ 
if($row<1) {
    echo "</tr>";
    echo "<tr>";
    echo "<td colspan='6' class='text-center pad25A'>No Record</td>";
    echo "</tr>";
}
else
{
foreach($row AS $key => $value){
    $row[$key] = stripslashes($value);
  } 
    echo "<tr>";  
    echo "<td><a href='customer-screen.php'>" . nl2br( $row['customer_name']) . "</td>";

    if(!empty($row['customer_details'])){
    echo "<td><a href='customer-screen.php'>". nl2br( $row['customer_details']) . "</td>";
        }
    else{
       echo "<td><a href='customer-screen.php'>-</td>";
    }
    if(!empty( $row['domain']))
    {
    echo "<td><a href='customer-screen.php'>". nl2br( $row['domain']) . "</td>";}
    else{
       echo "<td><a href='customer-screen.php'>-</td>";
    }
    if(!empty($row['vertical'])){
    echo "<td><a href='customer-screen.php'>". nl2br( $row['vertical']) . "</td>";}
    else{
        echo "<td><a href='customer-screen.php'>-</td>";
    }
    if(!empty($row['taxanomy'])){
       echo "<td><a href='customer-screen.php'>". nl2br( $row['taxanomy']) . "</td>";
    }
    else
    { echo "<td><a href='customer-screen.php'>-</td>";}

         echo $row['customer_id'];


    echo "<td>

    <a href='javascript:?id={$row['customer_id']}'    data-id={$row['customer_id']} class='btn small bg-blue-alt tooltip-button modal-customeredit' data-placement='top' title='Edit'><i class='glyph-icon icon-edit' ></i>

    </a>
    <a href='customer_delete.php?id={$row['customer_id']}'  class='btn small bg-red tooltip-button confirm' data-placement='top' title='Remove'><i class='glyph-icon icon-remove'></i>
   </a>
   </td>";}}


 ?>
            </tbody>
        </table>
      </div>

</div>   
</div><!-- #page-content -->
    </div>
            </div>
<?php include("footer.inc.php"); ?>

名称
细节
领域
竖的
分类法
行动
您应该了解如何将值传递给PHP

$( "#modal-customeredit" ).dialog({
     modal: true,
     minWidth: 700,
     minHeight: 200,
     dialogClass: "modal-dialog",
     show: "fadeIn"
     buttons: {
         Edit: function() {
           // Sample ajax request ( see the documentation)
           $.ajax({
               type: "POST",
               url: "request.php",
               data: { id: myGroupId }, // data retrieve on server-side ($_POST['id'])
               dataType : 'html|json|...' // expected data returned
           })
           .success(function( msg ) {
               alert( "Data Saved: " + msg );
           });
         },
         Cancel: function() {
           $( this ).dialog( "close" );
         }
    }
    // stop event when form is submit
    return false;
});
你完全有能力自己做这件事。还有一个建议,试着分开你的文件。例如,在另一个文件中作为request.php执行处理

编辑:

php的示例(我将返回json)



现在,数据将发送回.success(data)中的ajax函数。

您是否可以更清楚地知道,我必须在同一个页面上执行请求(在我的例子中是footer.inc.php)。我会将所有php代码(目标是执行sql语句)放在另一个名为request.php的页面中。AJAX允许您通过传递变量myGroupId中的id调用页面(无需重新加载页面)。您可以给我一个小演示,或者您可以将代码放在另一个页面上测试我的代码。这将对我有很大帮助。我已经更新了我的答案。下次我要花20美元/小时;)。我随时准备回答任何问题。但是请在学习AJAX之前花点时间。如果对您合适,请验证;-)。此外,您可以在Internet上找到许多关于Ajax(使用jQuery)的主题。
$( "#modal-customeredit" ).dialog({
     modal: true,
     minWidth: 700,
     minHeight: 200,
     dialogClass: "modal-dialog",
     show: "fadeIn"
     buttons: {
         Edit: function() {
           // Sample ajax request ( see the documentation)
           $.ajax({
               type: "POST",
               url: "request.php",
               data: { id: myGroupId }, // data retrieve on server-side ($_POST['id'])
               dataType : 'html|json|...' // expected data returned
           })
           .success(function( msg ) {
               alert( "Data Saved: " + msg );
           });
         },
         Cancel: function() {
           $( this ).dialog( "close" );
         }
    }
    // stop event when form is submit
    return false;
});
<?php
   header('Content-type: application/json'); // Tell the app that you want return json
   $id= $_POST['id']; // correspond to your retrieved data in ajax function

   // ... Your SQL request and other treatment

   // The result return
   echo json_encode($result);
?>