For example: {code...}. for example, in the above code, the url has obtained the relative address using the U method. If I directly use the url during post, the whole page will be returned. after the root is added, it can be used normally. Have you ever encountered a similar situation? And in some places:
var root=window.location.origin;$.post(root+"/"+url,data,function(d){ console.log(d); if(d.status==1){ location.reload(); }})
For example, in the above code, the url has previously obtained the relative address using the U method.
If I use a url directly during post, the whole page will be returned,
After the root account is added, it can be used normally.
Have you ever encountered a similar situation?
This is only true in some places, but not in general.
This page uses the Baidu editor. what is the impact?
Note:
The above may not be clearly expressed. the request address after I add root is: root + "/" + url,
When not added, the request is: url (I did not add "/" in front of it "/").
The url address is obtained on this page using the Thinkphp U method. of course, it can be accessed directly and the correct address; so I will have such questions.
Reply content:
For example:
var root=window.location.origin;$.post(root+"/"+url,data,function(d){ console.log(d); if(d.status==1){ location.reload(); }})
For example, in the above code, the url has previously obtained the relative address using the U method.
If I use a url directly during post, the whole page will be returned,
After the root account is added, it can be used normally.
Have you ever encountered a similar situation?
This is only true in some places, but not in general.
This page uses the Baidu editor. what is the impact?
Note:
The above may not be clearly expressed. the request address after I add root is: root + "/" + url,
When not added, the request is: url (I did not add "/" in front of it "/").
The url address is obtained on this page using the Thinkphp U method. of course, it can be accessed directly and the correct address; so I will have such questions.
The relative address is relative to the address bar of the current browser and has nothing to do with ThinkPHP.
/Is the root address. you can directly use/to indicate the access from the domain name +/+ url. if the root address is the root address, it will not be wrong, and the problem cannot be found;
If you use window. location. origin, it indicates that you use the relative address. the requested url is under the relative address window. location. origin;
You 'd better start your AJAX request path from the root directory and write the full path. This problem has nothing to do with tp, and your own understanding of the request address is incorrect.
base_url
Great way.