Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I a trying to AJAX a variable from a javascript/HTML file and recieve the variab

ID: 3787151 • 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:

Error:

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 processing

Explanation / Answer

500 is server error. This means that there is some issue with the server in either processing the file or executing operations. Once have a check on the server settings and also on the path of the file.

Are there any more code available in php file that is reading again another file or storing in DB? Because if this is working in your local and not in server, then the server is not having all the settings as the way it is in your local.

Make sure that whatever you need to run this code is available in server as well.