Question: I a trying to AJAX a variable from a javascript/HTML file and recieve the variable in a php file. It works on my localhost server,
I a trying to AJAX a variable from a javascript/HTML file and recieve the variable in a php file. It works on my localhost server, but after deploying my site the AJAX doesn't work.
Her is the javascript:

And here is my php file recieving the variable:

314 315 316 317 318 319 320 321 3324 328 335 336 function showTweetsO 1 Create our XMLHttpRequest object var hr new XMLHttpRequest Create some variables we need to send to our PHP file var url my parse file.php"; var selopt3 document getElementByIdC" choice2").value var vars selopt3 console. log(vars); hr.openC"POST", url, true) Set content type header information for sending url encoded variables in the request hr.setRequestHeaderC" Content-type", "application/x-www-form-urlencoded"); Access the onreadystatechange event for the XMLHttpRequest object hr onreadystatechange function C) if Chr .readyState 4 && hr. status 200O 1 var return data r. responseText document getElementByIdC"status").innerHTML return data Send the data to PHP now. and wait for response to update the status div Actually execute the request hr. open "GET", "my parse file.php?username +vars,true) hr .send(vars); document getElementByIdC"status").innerHTML processing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
