I a trying to AJAX a variable from a javascript/HTML file and recieve the variab
ID: 3787149 • Letter: I
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, but after deploying my site the AJAX doesn't work.
Her is the javascript:
Here is the PHP Script:
This is the error I am getting when the site is deployed:
function showTweetsO 1 Create our XMLHttpRequest object var hr new XMLHttpRequesto; Create some variables we need to send to our PHP file var url "/home2/passeng7/public html/parsefile .php"; var selopt3 document getElementByIdC"choice2") value var vars selopt3 console. log(vars); r Open 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 O hr. onreadystatechange function ifChr.readyState 4 && hr. status 200) 1 var return data hr. responseText document innerHTML return data Send the data to PHP now. and wait for response to update the status div Actually execute the request hr. openC"GET", "parsefile.php?username +vars, true); hr Sen document.getElementByIdC"status") innerHTML processingExplanation / Answer
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Match Username against Database using PHP
This PHP script is executed as a result of the jQuery AJAX call. It compares database and user data to check username. Based on the availability status it will respond to the AJAX call.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.