简体   繁体   中英

JQuery .post method problem with comma in php

This Works fine and count returns 2:

$request_ids="166409183417843,1913616994605";
$sent   = explode(',',$request_ids);
$count = count($sent);

But when using Jquery to post to another page sent var returns only the last id and count returns 1.

Page of origion:

$(function(){
      $.post("process_ids.php", { request_ids: response.request_ids } );})

process_ids.php file:

$sent   = explode(',', $_POST['request_ids']); 
$count = count($sent); 

I also checked with alert() the value of response.request_ids value and it's the same. Something is totally screwed here, what's wrong?

I hate answering my own question but it's better than no answer. The problem was like some mentioned above - the data type of the variable.

I simply cast the string to it before sending:

$(function(){
      $.post("process_ids.php", { request_ids: String(response.request_ids) } ); 
      return false;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM