Troubleshooting the process of HTTP request response 500, jQuery property operation – attr() method, setting the src attribute to cause
1. After the upload of the picture is successful, the GET request:https://console.xxx.cn/upload/20210319/20210385015127.png, the response 500. The root cause is that the domain name of the image after the upload is successful is not:https://console.xxx.cn, but:https://web.xxx.cn. as shown in Figure 1
2. Open the Initiator tab, view the request call stack, and execute the GET request on line 516 of the page. as shown in Figure 2
3. Click to enter, the JS code is as follows. jQuery property operation – attr() method, set the src property. as shown in Figure 3
goodsSl.on('uploadSuccess', function (file, json) {
$('.edit_img_tipthumb').attr("src", json.theUrl);
$('input[name="data[Product][thumb_img]"]').val(json.theUrl);
})
4. The value of json.theurl: /upload/20210319/20210385015127.png. Decide to use the absolute address and add the domain name prefix:https://web.xxx.cn. The editing code is as follows
goodsSl.on('uploadSuccess', function (file, json) {
$('.edit_img_tipthumb').attr("src", 'https://web.xxx.cn/creditshop_back' + json.theUrl);
$('input[name="data[Product][thumb_img]"]').val(json.theUrl);
})
5. After the upload of the picture is successful, the GET request:https://web.xxx.cn/upload/20210319/20210385015127.png, the response 200. as shown in Figure 3



