Jquery Array Push Strings Not Passing Through POST

34 Views Asked by At

I am trying to Pass a comma separated Id values to PHP using Jquery Post. I have below code in my Jquery

var values = [];
  $('tr#trdata td:nth-child(1)').each(function () {
  values.push("'"+$(this).html()+"'");
});

Above code is out putting value like this '238','239','240','241','242','243','244','245','246'

I am then Trying to post above value using below code

$.ajax({
      url : "mypage.php",
      method:"POST",
      dataType:"text",
      cache:false,
      data:{page_no:values, type: type, keyword: keyword},
                                                                
      success:function(data){
      }
});

And in my php I am trying to get the value with below code

if (isset($_POST['page_no'])) {
  $page = $_POST['page_no'];
}else{
  $page = 0;
}

I am getting the comma separated values in console correctly but in php it is always empty what is the wrong I am doing?

0

There are 0 best solutions below