开发者

Issue on passing a checkbox set to an AppEngine script through jQuery Ajax/Json

开发者 https://www.devze.com 2022-12-28 08:13 出处:网络
I have a set 开发者_高级运维of checkboxes with multiple choice allowed. I parse the set this way:

I have a set 开发者_高级运维of checkboxes with multiple choice allowed. I parse the set this way:

if ($("input[name='route_day']:checked").length > 0) {
    $("input[name='route_day']:checked").each(function(){
     if(this.value != null)
  route_days_hook.push(this.value); 
  });
  dataTrap.route_days = $.JSON.encode(route_days_hook);
}

...and pull the whole dataTrap to an AppEngine Python script via jQuery ajax. However, the Python script just bugs. If i change dataTrap.route_days value to a string instead of the JSON encoded object, everything works fine.

My question is: how can i pass a checkbox set to the script using Ajax and still be able to iterate over it on the script?


have you tried:

 dataTrap.route_days = $.parseJSON(route_days_hook);

EDIT

if that didn't work, maybe it's because you are trying to convert an array object to JSON...

try this solution instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号