简体   繁体   中英

jQuery serialize inputs on form submit, but not with ajax

Is there no way of submitting a serialized parameter without ajax?

I want to access, like, an json encoded parameter when I process the POST from the form, something like: $params = json_decode($_GET['params']);

Any ideas, besides iterating each input and append it to a hidden one that will contain all parameters in an encoded form, ?

Update

I'm using codeigniter, so I would rather do something like

$search = json_decode($this->input->get('params'));
updateName($search['name']);
updateGender($search['gender']);

Than

updateName($this->input->get('name'));
updateGender($this->input->get('gender'));

Not sure if I am missing something here but you can only do a json_decode() on a json object/array.

$this->input->get() will return the whole $_GET array AS A PHP ARRAY, so you dont need to do anything JSON'ick with it to be able to use it as an array.

so would this not do what you want?

$search = $this->input->get();
updateName($search['name']);
updateGender($search['gender']);

If you want to pass it through the XSS filter first just use

$search = $this->input->get(NULL, TRUE);

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