AJAX POST不发送数据而是通过GET方法发送

时间:2017-10-24 06:40:35

标签: jquery ajax

This is my jQuery function

网络输出:

enter image description here

function view_cet() {
  var action = "select";
  var fname = $("#fname1").val();
  var lname = $("#lname1").val();
  var bdate = $("#bdate1").val();
  var type = "C";

  if (fname != '' && lname != '' && bdate != '') {
    $.ajax({
      url: "../include2/fetch-cet-sase.php",
      method: "POST",
      dataType: "json",
      contentType: "application/x-www-form-urlencoded",
      data: {
        action: action,
        fname: fname,
        lname: lname,
        bdate: bdate,
        type: type
      },
      success: function(data) {
        $("#output").html(data);
        console.log(data);
      }
    });
  } else {
    alert('First name, Last name and Date of birth should not be empty. Pleas input a value.');
  }
}

1 个答案:

答案 0 :(得分:0)

使用Jquery.post()

解决了这个问题



$.post( "../include2/fetch-cet-sase2.php",
{ fname: fname, lname: lname, bdate: bdate, reqtype: reqtype })
.done(function( data ) {
			$("#output").html(data);
			$("#btn-modal1").click();
});




无论如何,谢谢你的回复:)