POST方法无法在swift 3.0 Alamofire 4.0中运行?

时间:2016-11-30 12:03:46

标签: ios swift3

以下是我的参数

$('#back-button').click(function(){
     $('#formular-content').load('/eshop/formular/1.php',function(){
          $( "#slider-range" ).slider({
               range: true,
               min: 0,
               max: 500,
               values: [ 75, 300 ],
              slide: function( event, ui ) {
                 $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
              }
          });
          //initialise anything here as in .slider() to the `element` which is loaded through ajax.
     });
});

和post方法函数包含以下代码

 var comment: [String:AnyObject] = [:]
 comment  = [
            "txtUsername": (txtUsername?.text)! as AnyObject,
            "txtPassword": (txtPassword?.text)! as AnyObject
        ]

这里的目标c我的webservice工作成功,但在使用此代码时,它总是给出响应“false”......这段代码中是否有任何错误。

1 个答案:

答案 0 :(得分:0)

很多事情都可能出错。如果我要调试,我会检查一些事情:

  1. 如果我想使用PNG,我可能会在此代码中使用UIImagePNGRepresentation(...)而不是UIImageJPEGRepresentation
  2. 如果我想使用JPEG,我会将multipartFormData.append(imageData, withName: "file", fileName: "file.png", mimeType: "image/png")更改为multipartFormData.append(imageData, withName: "file", fileName: "file.jpg", mimeType: "image/jpeg")
  3. 如果(2),请尝试将UIImageJPEGRepresentation(image, 1)更改为UIImageJPEGRepresentation(image, 0.5)。它可能会失败,因为图像太大,因此应用更高的压缩可能会发现问题。