Cross Origin Resource Sharing

buckibooster

Member
Nov 22, 2018
11
2
3
Florida
cPanel Access Level
Website Owner
I'm encountering a problem I've never seen before and could certainly use some help. I've developed a web site for a local community chorus which consists of a main php page, two (2) javascript files, a single styling sheet file and two (2) php files used to make AJAX calls. I should emphasize that this web site is fully functional and working well on my development site at Bluehost. Earlier this week, I started migrating this web site to the chorus' server at GoDaddy. When I did, I encountered a problem with both of my AJAX calls. The AJAX calls are being made but the response is not getting through the javascript httprequest functions. Both AJAX calls originate from my main page through javascript function calls to an AJAX-specific php file (a different php file for each AJAX call). The php file is supposed to process my request and send a response back to the javascript function calls for further processing. Processing in each of the php files seems to be working just fine but the response is not making it back to javascript function calls. Technical support at GoDaddy has not been of any assistance in resolving this issue.

I'm not getting any message on my console log but I am getting a 500 error from the network (Firefox developer tools). In reading about this, I'm further confused because all of the resources being used are within the chorus' domain. In other words, I am not trying to get data from another domain. One of the AJAX calls queries an underlying SQL database to create the response. The other AJAX call does not access any other resources. Its this latter function that has been giving me the most problems. The only other thing that might be affecting this is that the main page for the web site is stored in the Root directory while all other relevant files are stored in a sub-directory of the Root directory (i.e., /included_files). Can anyone shed light on the cause(s) of this problem and what I can do to resolve it? Your help will be very much appreciated.
 

buckibooster

Member
Nov 22, 2018
11
2
3
Florida
cPanel Access Level
Website Owner
Hi @buckibooster

I'm really glad to hear that you were able to resolve the issue. What did end up causing the issue?
Lauren:

It was an encoding issue. Although all relevant files were saved and uploaded with utf-8 encoding, the AJAX call had to use the following setRequestHeader (xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");).
 
  • Like
Reactions: cPanelLauren