Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX from javascript to php not working after SSL upgrade

    As in the title:

    I have many .js files, all of which point to a php mailer, which sends the results of the browser back to the user via email.

    html > javascript > php > email

    These all work fine on a site without SSL, i.e. an http:// non-secure protocol website, such as MYP Chemistry forum and notes, but not on https://ibchem.com. I have all of the files located in folders on IB Chemistry revision notes and syllabus, which worked fine before the upgrade to SSL, but which now do not work.

    Javascript function:

    Code:
    function postIt() {   
    var http = new XMLHttpRequest();
    var url = "../mail/summary.php";
    var params = "realname="+myName+"&rightAnswers="+correct+"&percentageScore="+percentage+"&wrongArray="+wstore+"&asked="+numq+"&mins="+minutes+"&secs="+seconds+"&deliver="+destination+"&testName="+test;
    http.open("GET", url+"?"+params, true);
    http.onreadystatechange = function() {   //Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        //alert(http.responseText);
    }
    }
    http.send(null);
    }
    php file (only the reception of data shown):

    PHP Code:
    $data1=$_GET["realname"];
    $data2=$_GET["rightAnswers"];
    $data3=$_GET["asked"];
    $data4=$_GET["mins"];
    $data5=$_GET["secs"];
    $data6=$_GET["percentageScore"];
    $data7=$_GET["deliver"];
    $data8=$_GET["testName"];
    $myWrongArray explode(','$_GET["wrongArray"]);

    $sendTo "[email protected]".", ".$data7;
    $subject $data8." summary results for ".$data1
    Anyone have any idea of the problem or a possible solution?

    Cheers,

    Charco

    Please scrub all of the above! It turns out that my web server had flagged all output from the php file as spam! I'm very sorry for wasting anyone's time. It took them (ipowerweb) two days to find out the problem was the server side. I don't know how to delete ...
    Last edited by charco; Sep 11th, 2018 at 07:45 PM.

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    7,996
    Thanks
    36
    Thanked 1,072 Times in 1,068 Posts
    Is this your real JS code? I don't see how your passing the variable myName, correct, percentage, and all the others.

    Most importantly is your open() function, which does not include the url:
    Code:
    http.open("GETl+"?"+params, true);
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. #3
    New Coder
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    Is this your real JS code? I don't see how your passing the variable myName, correct, percentage, and all the others.

    Most importantly is your open() function, which does not include the url:
    Code:
    http.open("GETl+"?"+params, true);
    Thanks for dropping by. I have found the problem, which was a server configuration and they fixed it.

    But I still have an issue with degree signs. If the HTML file has a meta tag with UTF-8 then the screen display does not show the degree sign (made with Spanish keyboard setting, ) it shows a black diamond with a question mark in the middle. I can't use ° as the & breaks the php that the string gets sent to.

    My question is "how do I display a degree sign in normal HTML?" If I leave the Meta tag characterset declaration then the display does not work.

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    Here is an example string:

    "<p>1. The heat capacity of a bomb calorimeter is 1.16 kJ K<sup>-1</sup>. Calculate the energy needed (kiloJoules) to increase the temperature of the calorimeter by 45C. (to 3 significant figures)</p>";

    It does not render in HTML unless I remove the meta tag (but this can't be correct, surely). But if I remove it using comments:

    <!-- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -->

    It works fine.

    I'm very puzzled by all of this ...

  4. #4
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    7,996
    Thanks
    36
    Thanked 1,072 Times in 1,068 Posts
    The meta S/B <meta charset="utf-8"> I'm sure you do have the quotes, I'm just checking. And using an echo in php to output this works for me
    Code:
    <?php
    echo "<p>1. The heat capacity of a bomb calorimeter is 1.16 kJ K<sup>-1</sup>. Calculate the energy needed (kiloJoules) to increase the temperature of the calorimeter by 45&degC. (to 3 significant figures)</p>;";
    ?>
    Maybe more bad configuring on your servers part.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •