0
I’m learning how to use the React Framework. In the sending part of form data, and recover this data, I am using ajax with the function of jQuery.
componentDidMount() {
$.ajax({
url:"http://localhost:80/contatos/dados-json.php",
dataType:'json',
success:function(clientes){
this.setState({lista:clientes});
}.bind(this)
});
}
Only this URL to whom I am requesting is from another server that is located on my machine (a Xampp server).
Translated, they are two local servers on the same machine
In case it’s like this:
- React está - localhost:3000 (npm create-React-app)
- PHP and BD files - localhost:80 (Xampp)
The problem with this is that I keep making cross server requests, and end up giving more problems to work.
I wanted to know how to put: PHP and BD files on the same React server?
The PHP server is on the same machine as REACT, but on different local servers, one ta on localhost:3000 and the other localhost:80, the way ta ai, ta is working, but it is complicated because it is cross server, I want to put these PHP and BD files on the same REACT server, you know? @wmsouza
– Rodrigo Jacinto
I am using, npm create-React-app, already comes with Node, webpack etc installed
– Rodrigo Jacinto
React: C: Users W8 Desktop curso-React PHP files: C: xampp htdocs contacts
– Rodrigo Jacinto
Take the files, HTML and Javascript that were compiled by Webpack and put inside a directory on your server PHP.
– NoobSaibot
But I lose Node.js? resources or React will use it the same way?
– Rodrigo Jacinto
The features that your application will use will be compressed by Webpack, your application will work normally, only by a server PHP. It’s like you put your website on the server, and that’s it.
– NoobSaibot
Um entendi vlw
– Rodrigo Jacinto
Rodrigo, did you get a solution? I have the same problem
– Lucas Oliveira