ios - Error fetching swift post variables -


I created an HTTP post request in Swift iOS. When I get a post variable in the php file, it looks empty, I can not find the variable value under my swift code, look at it. Data = name = john & type = student "var request: NSMutableURLRequest = NSMutableURLRequest () request.URL = NSURL (string:" http: /www.example.com/ Example.php ") PostString = (DustString as NSString) .DetUsing Encoding (NSUTF8StringEncoding) request.HTTPMethod =" POST "request.setValue (" Application / Jason ", forHTTPHeaderField:" Content-Type ") Request.HTTPBody = postString Var connection = NSURL connection (request: request, delegate: self, initial: wrong) Func connection (didReiveiveResponse: NSURLConnection !, didReiveiveResponse response: NSURLResponse!) {// New request Need to clear the tattoo object println (response)}

PHP code:

    

Anyone can suggest what I should do for variable values. Thank you

You Content-Type of application / Application / json instead of x-www-form-urlencoded

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -