OC 如何将{"message":{"function":"user_login","user":{"name":"admin","password":"admin"}}}将这个登录请求json通过socket TCP发给服务器
伊谢尔伦2017-05-02 09:26:33
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 发出去就可以了
漂亮男人2017-05-02 09:26:33
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")
}
});
黄舟2017-05-02 09:26:33
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?