Home  >  Q&A  >  body text

javascript - How does php process the values ​​of the serialized form and convert them into the form corresponding to the key value?

Rookie for advice

Use $.ajax to submit,

$.ajax({
               type: "POST",
               url: 'getData.php',
               async: false,
               data: $('#guestbook').serialize(),
               error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    },
               success: function(data){
                alert(data);
               }
            })
            

The serialized value obtained in the background is in the form of name1=value1&name2=value2&name3=value3 ...

$data = file_get_contents("php://input");
$str = urldecode($data);    

How to convert the obtained data into an array or json, and the key value corresponds

曾经蜡笔没有小新曾经蜡笔没有小新2715 days ago493

reply all(1)I'll reply

  • 迷茫

    迷茫2017-06-05 11:09:30

    parse_str

    reply
    0
  • Cancelreply