search

Home  >  Q&A  >  body text

javascript - res can be printed under Chrome, but the values ​​returned by Response and Preview cannot be seen under F12

1. Request written with vue-resource.
2. The code is as follows:


The following is the 200 data returned by this request. I printed it out, as shown below:


Then the problem is, when I click on Preview and Response, I can’t see the return value, as shown below:


What is the reason. . . [Note: This is a cross-domain request]

!!!Supplement: [This is a post request]

Moreover, I tested it in Firefox and found that I can get the values ​​returned by Response and Preview. The initial conclusion is that it's Google's problem.

巴扎黑巴扎黑2844 days ago784

reply all(6)I'll reply

  • 为情所困

    为情所困2017-05-16 13:44:08

    Chrome 56 and above will have this problem when making cross-domain requests locally. The solution is:

    1. Back to version 55

    2. You should now perform cross-domain requests by setting Access-Control-Allow-Origin. If possible, set proxyTable to perform cross-domain requests during local debugging

    This problem has been bothering me for a long time, and I also want to know if there is a more reasonable method

    reply
    0
  • PHPz

    PHPz2017-05-16 13:44:08

    Please change the browser and take a look. I've encountered it before, sometimes it's there and sometimes it's not, but it doesn't matter.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:44:08

    This problem occurs only when Request Mehod is options

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:44:08

    I have encountered this problem before, because the content-type returned by this address is not json format, but octet-stream, binary data, so what is displayed is a blob object, which seems to be mainly used to download files. I will update vue later. -After the version of resource, it will be automatically converted to json, or you can use the reader to read it again and then convert it to json

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:44:08

    The method of your request is options. It is to determine whether cross-domain requests are allowed, not the actual request. There should be another request with the same URL and the method is post, which is the actual request.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:44:08

    Added a little bit later.

    reply
    0
  • Cancelreply