Answer the question
In order to leave comments, you need to log in
What to write as url in fetch js command when working on OpenServer on local computer?
I'll make a reservation right away, I'm a beginner, I know little.
I have OpenServer installed on my local computer.
Installed in order to be able to work with php.
Now I am trying to solve the following problem.
My php file opens (file_get_contents) some external html file from web.
Further, it edits the received string in some way, in particular, what is important, adds
" " to it.
Next, it prints (echo) it, as a result of which my myScript.js works out.
myScript.js gets some js object obj.
Now I want to send this json to the server (so that I can then process it using php).
To do this, I write at the end of my myScript.js a construction like<script src='myScript.js'></script>
fetch('url', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: 'json=' + JSON.stringify(obj)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question