douyao2529 2014-03-07 04:15
浏览 45

Ajax没有将变量发布到另一个页面

Hi I have problem of sending my variable to another PHP page using ajax. My problem is am getting the id of the element from main page. Its for edit operation.

Main page modal:

  <a href='javascript:' 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>

it will open modal on same page:

<div class="hide" id="modal-projedit" title="Edit Project Info">
<div class="pad10A">
<h3>Edit Project Info</h3>
<p class="font-gray-dark"> Fides Admin uses colors & styles from both the default theme color schemes and the included core color helpers. </p>
<div class="divider mrg25B"></div>
<form id="project-edit" action="" class="col-md-12 center-margin" method="">
<div class="form-row">
<div class="form-label col-md-3">
<label for="name">
  Project Name:
  <span class="required">*</span>
  </label>
</div>
<div class="form-input col-md-9">
<input id="project_name" name="project_name" placeholder="Name" data-required="true" class="parsley-validated" type="text">
</div>
</div>
<div class="divider"></div>
<div class="form-row">
<div class="form-input col-md-8 col-md-offset-3">
<a href="javascript:;" class="btn medium primary-bg radius-all-4" id="project-edit-valid" onclick="javascript:$('#project-edit').parsley( 'validate' );" title="Validate!">
  <span class="button-content">
    Update
    </span>
  </a>
</div>
</div>
</form>
    </div>    
</div>

SCRIPT:

$( ".modal-customeredit" ).click(function() {


       var myGroupId = $(this).data('id');
          alert( myGroupId);          
            $.ajax({
               type: "POST",
               url: "sample.php",
               data: { id: myGroupId }, // data retrieve on server-side ($_POST['id'])

           })




       $( "#modal-customeredit" ).dialog({
         modal: true,
         minWidth: 700,
         minHeight: 200,
         dialogClass: "modal-dialog",
         show: "fadeIn"
       });
       $('.ui-widget-overlay').addClass('bg-black opacity-60');

     });        

     });
  • 写回答

4条回答 默认 最新

  • doukan5332 2014-03-07 04:29
    关注

    You didn't mention what the alert says.

    Though I guess it shows a Null value since the ajax request seems good.

    My bet goes for your selector, try this :

    var myGroupId = $(this).attr('data-id');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教