0

Problem Context

I'm developing a subscription system for a database / web-based front-end, which will allow users to subscribe to notifications for comments on individual events, and to comments on all events in the states they select.

I have developed a few tables for this, and implemented them into my database, along with a few stored procedures to perform various tasks (add a user, subscribe a user to notifications for comments on an individual event, unsubscribe a user from notifications for comments on all events in a selected state... you get the idea)

Anyway, all seems to be working well, in Chrome. However, in Internet Explorer 9, the piece of code which handles subscribing and unsubscribing to states does not seem to be working consistently (despite working perfectly in Chrome), and I am not sure why.

Details

When the user clicks a "Manage Subscriptions" link, a pop-up will appear with a query-generated list of all states in the areas being covered.

It includes the following script which passes necessary info to the ajax itself -

<script type='text/javascript'>

        $(document).ready(function(){
            $('.checkbox').change(function(){
                var UserID = <?php echo json_encode($_POST['UserID']); ?>; 
                var State = $(this).val(); 
                var Subscribed = $(this).prop("checked"); 
                console.log($(this).val() + " - " + Subscribed);

                $.ajax(
                {
                    dataType: "html", 
                    url: <?php echo "'" . $root . "updatesubscriptions.php" . "',"; ?> 
                    type: "POST",
                    data: 
                    {
                        UserID: UserID,
                        State: State,
                        Subscribed: Subscribed
                    }, 
                    complete: function(result)
                    {

                    }
                });
            });
        }); 

        function closeWindow() 
        {
            close(); 
        }

</script>

And the ajax itself -

<?php 

session_start(); 

header("Content-type: text/plain");
$connection = new mysqli('localhost', 'user', 'password', "database");

if ($_POST['Subscribed'] == "false")
{
    $connection->query("CALL User_UnsubscribeFromState('" . $_POST['UserID'] . "', '" . $_POST['State'] . "');");
    $connection->next_result(); 
}
else 
{
    $connection->query("CALL User_SubscribeToState('" . $_POST['UserID'] . "', '" . $_POST['State'] . "');");
    $connection->next_result();
}



?>

Attempts at a Solution so far

  • In honesty, I haven't been able to take many steps so far. I am at a loss as to how it works so consistently in Google Chrome and does not work in Internet Explorer. I have tried console.log() in complete: function(result) to debug which works in Google Chrome but does not seem to work in Internet Explorer. I'm not sure where to go from here.

  • I see this post discussing issues in Internet Explorer, however it is not cross-domain and there are other ajax requests (such as adding a comment) which work as expected.

Community
  • 1
  • 1
Eilidh
  • 1,270
  • 1
  • 13
  • 33
  • 1
    Have you watched the request / response in the browser's console? Are you seeing anything unusual in IE? – Jay Blanchard Jan 21 '15 at 13:51
  • 2
    Try commenting out the console.log ... found that IE really doesn't like that. Technically, there is no console until the user presses F12 and opens it; until then the code errors and stops at that point. – rfornal Jan 21 '15 at 13:53
  • The console in Chrome shows me `XHR finished loading: POST ... ` followed by more information but the console in IE does not seem to show anything like that. – Eilidh Jan 21 '15 at 13:53
  • Aha! Thank you rfornal - it seems the error was indeed IE throwing a hissy fit about `console.log` - great catch! :) – Eilidh Jan 21 '15 at 13:55
  • (I'm not sure what the courtesy is here - I'd like to close the question to avoid people think it is un-solved but I don't want to take credit for rfornal's solution - what should I do? Thank you) – Eilidh Jan 21 '15 at 14:03

0 Answers0