Retrieving HTTP status code from loaded iframe with Javascript

后端 未结 2 1337
野性不改
野性不改 2020-11-29 06:17

I used the jQuery Form plugin for asynchronous form submission. For forms that contain files, it copies the form to a hidden iframe, submits it, and copies back the iframe\'

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 07:05

    You can't retrieving HTTP status code from loaded "iframe" directly. But when an http error occured, the server will returned nothing to the "iframe". So the iframe has not content. you can check the iframe body, when the body of iframe is blank, use ajax with the same url to get the response from server. Then you can retrieve the http status code from response.

提交回复
热议问题