I have a form that contains file upload inputs, I use iframe to submit those files and the rest data via ajax:
<form id="myform" action="/megogo/web/index.php?r=form/create-order" method="post" enctype="multipart/form-data" target="upload_target">
..inputs, file inputs..
</form>
<iframe id="upload_target" name="upload_target" src="#"></iframe>
I receive data correctly on the server, but I cannot send response status back to the client:
public function actionCreateOrder(){
//gettting data from $_POST
$status = 1;
\Yii::$app->response->format = Response::FORMAT_JSON;
return $status;
}
Now when form is submitted I receive:
$("#myform").submit( function(e){
$.ajax({
success: function (response)
{
console.log(response);
}
});
});
I get html page for response and the message Resource interpreted as Document but transferred with MIME type application/json:. How can I access my status instead?
I cannot change enctype because I will not receive uploaded files then. Id appreciate any advice.
jQueryscript I just want to get response. If I use$.ajax()to postform.serialize(), I wont receive files.\yii\rest\controllerinstead of\yii\web\controllerwon't be an option here ? (check this)