dongrong9053 2016-10-25 09:22
浏览 77

我在javascript中得到了ajax响应但现在我想提交表单并希望在我的POST数组中也有ajax响应

I want to add data in database for that i want the ajax responce array also in the POST array but havent do that

<div class="form-group">
  <label for="focusedinput" class="col-sm-2 control-label">Campus Accreditation</label>
  <div class="col-sm-7">
    <?php Web_Interface::load_accreditation($obj_admin->adminCountry); ?>
    <script>
      jQuery("input[id=accreditation]").click(function() {
        var selectedCheckBoxArray = new Array();
        var n = jQuery("input[id=accreditation]:checked").length;
        if (n > 0) {
          jQuery("input[id=accreditation]:checked").each(function() {
            selectedCheckBoxArray.push($(this).val());
          });
          //send check box data value array to server using Ajax
          var data = {
            myCheckboxes: selectedCheckBoxArray
          };
          jQuery.ajax({
            url: "../process/ProcessAjaxChecking.php",
            data: data,
            type: "POST",
            success: function(data) {
              $('#getAcademics').html(data);
              $json = json_encode(data);
              $.ajax({
                url: "Example.php",
                type: "POST",
                dataType: "json",
                success: function(msg) {
                  $('#getAcademics').html(data);
                }
              });
            }
          });

        }
      });
    </script>
  </div>

Before Submit Form enter image description here

After submit From enter image description here

  • 写回答

1条回答 默认 最新

  • dongtuo5262 2016-10-25 09:32
    关注

    In your value.php you have given name 'academicsCheckBoxesand you have paased in ajaxmyCheckboxes`.

    Change

    var data = {
        academicsCheckBoxes: selectedCheckBoxArray 
    };
    

    Updated Code

    <div class="form-group">
      <label for="focusedinput" class="col-sm-2 control-label">Campus Accreditation</label>
      <div class="col-sm-7">
        <?php Web_Interface::load_accreditation($obj_admin->adminCountry); ?>
        <script>
          jQuery("input[id=accreditation]").click(function() {
            var selectedCheckBoxArray = new Array();
            var n = jQuery("input[id=accreditation]:checked").length;
            if (n > 0) {
              jQuery("input[id=accreditation]:checked").each(function() {
                selectedCheckBoxArray.push($(this).val());
              });
              //send check box data value array to server using Ajax
              var data = {
                academicsCheckBoxes: selectedCheckBoxArray 
              };
              jQuery.ajax({
                url: "../process/ProcessAjaxChecking.php",
                data: data,
                type: "POST",
                success: function(data) {
                  $('#getAcademics').html(data);
                  $json = json_encode(data);
                  $.ajax({
                    url: "Example.php",
                    type: "POST",
                    dataType: "json",
                    success: function(msg) {
                      $('#getAcademics').html(data);
                    }
                  });
                }
              });
    
            }
          });
        </script>
      </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?