OC 如何将{"message":{"function":"user_login","user":{"name":"admin","password":"admin"}}}将这个登录请求json通过socket TCP发给服务器
I know the answer. I tried it myself and just wrote it `NSDictionary *dict = @{
@"message":@{ @"function":@"user_login", @"user":@{ @"name":_TextField.text, @"password":_PassTextField.text }}};` 将字典转成NSData在转成NSSString后面拼接上数据包的结尾,之后在转换成NSData通过tcp 发出去就可以了
Send data via ajax request
var url = "http://www.xxx.com" var data = {"message": {"function":"user_login", "user":{ "name":"admin", "password":"admin" } } } $.ajax({ cache: true, type: "POST", url: url, data: data async: false, error: function(request) { alert("NO"); }, success: function(data) { alert("OK") } });
It is not recommended to manually operate the socket to complete things like sending login requests. Why not try a mature network framework such as AFNetworking?
I know the answer. I tried it myself and just wrote it
`NSDictionary *dict = @{
Send data via ajax request
It is not recommended to manually operate the socket to complete things like sending login requests. Why not try a mature network framework such as AFNetworking?