Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Cross Origin Resource Sharing

Discussion in 'Security' started by buckibooster, Nov 22, 2018.

  1. buckibooster

    buckibooster Member

    Joined:
    Nov 22, 2018
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    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.
     
  2. buckibooster

    buckibooster Member

    Joined:
    Nov 22, 2018
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Florida
    cPanel Access Level:
    Website Owner
    My problem has been resolved. It was not a CORS issue after all.
     
  3. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,248
    Likes Received:
    478
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @buckibooster

    I'm really glad to hear that you were able to resolve the issue. What did end up causing the issue?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. buckibooster

    buckibooster Member

    Joined:
    Nov 22, 2018
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Florida
    cPanel Access Level:
    Website Owner
    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");).
     
    cPanelLauren likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice