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 val开发者_开发问答ue 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;
});
精彩评论