Having trouble getting the AJAX script to change the background in Internet Explorer?

I'm currently experiencing an issue with an ajax script. Here is the code I am using:

<script type="text/javascript">

    $(document).ready(function() {
        $('#savecolor').click(function(){     
          var myVar = 'data='+$('#color').val();
          $.ajax({
            type: "POST",
            url: "addcolor.php",
            data: myVar,
            success: function(msg){
            //alert(myVar);
            $('#message').html('The background color has been changed successfully.');
            $(window.parent.document).find('#set').css('background', msg);
             //$('#set').css('background', msg);
              // window.parent.location.reload(); 

               }
              });
             });
</script>

Although this code works well, it seems to have trouble in IE when utilizing jquery-1.7.

If anyone can provide assistance, I would greatly appreciate it.

Answer №1

In my opinion, the best fix would be to swap out

$(window.parent.document).find('#set').css('background', msg);
with
$('#set').css('background', msg);

For those using Internet Explorer, try using alert(msg) to check what value the function is returning.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an Uncaught TypeError: Attempting to call a controller function using AJAX in Magento results in undefined not being a function

I've developed a custom module in the admin panel called createadmincontroller. It's configured in the config.xml file. I'm trying to call the controller index function from a .phtml file using Ajax, but I keep getting an error that says "Un ...

Ways to modify the cursor of a disabled ImageButton on an ASP.Net webpage

Within a ListView, I have dynamically generated ImageButtons. If an image does not have a link, I want to make it disabled. In the ItemDataBound event, I attempted the following approach: img.Enabled = False img.DescriptionUrl = "javascript:void(0);" img. ...

Preserving the background image on an html canvas along with the drawing on the canvas

Can users save both their drawings and the background image after completing them? var canvas = document.getElementById("canvas"); // This element is from the HTML var context = canvas.getContext("2d"); // Retrieve the canvas context canvas.style.ba ...

Trigger a JavaScript function on a body click, specifically targeting certain elements to be excluded

I have a dropdown menu within a div element. I've created a javascript function called HideDropdown() that hides the menu when any main link on the page is clicked, except for links within the dropdown menu itself: <script> function HideDropdow ...

Click on the entire table to be redirected to the specified link

Currently, I am facing an issue with styling my tables as links. I have 3 tables and I want each table to be a clickable link. However, after implementing the links, I am unable round the corners of the tables. I envision the final look to be similar to t ...

Using jQuery to select and check the appropriate checkbox within a table cell

I have encountered an issue that can be found here. The problem arises when I try to click on a TD element and toggle the checkbox inside it. This works fine for checkboxes directly inside TD elements, but when there is a table nested inside a TD, the so ...

Is there a way to incorporate a deletion feature within a list of items using JavaScript?

When adding a new item, I want to include a delete button next to it so I can easily remove the item by clicking on the button. However, I am having trouble figuring out how to implement this functionality using JavaScript. You can view my code snippet he ...

Is there a way to make a text area box visible using JavaScript?

Currently, I am developing an automation script in Python using Selenium. My objective is to make a textarea box visible, as I need to insert some arguments into it. Here is the code snippet that I am utilizing: element = driver.find_element_by_id('g ...

Guide on redirecting a URL with AJAX in just 5 seconds!

How can I achieve a redirect to a specific URL after a successful sign-up using AJAX without losing the response from the AJAX call? Below is the code snippet I am currently working with: sign-up.php if ( $stmt->execute() ) { $response['status&ap ...

Browser encountering HTTP response that has been shorted extensively

When making an HTTP post request using axios, I am encountering an issue where the body of the response is a large 4MB string. axios({ method: 'POST', url: url, data: data, headers : headers, }) .then(function (response) { co ...

When using Browserify, the function require() on a concatenated string will not include the module in the output script

When using require() to create a combined string path, the path of the module will not be included in the output script. Examples of this include: require("./"+"b" ); //or var path="./"; require(path+"b"); Let's say we have a.js module.exports="a"; ...

Issues with the initial calculator project I built using JavaScript (excluding HTML and CSS)

My first calculator is nearly complete, but I have encountered a challenge. The functionality of my calculator is quite simple; it prompts the user for input using window.prompt and performs addition, subtraction, multiplication, or division based on the u ...

Guide to creating a dynamic illumination using CSS, HTML, and JS

Can you help me create a unique lighting effect for a specific section of my webpage? I'm curious about the techniques needed to achieve a similar effect as seen on another webpage. Is it feasible to create this effect using only CSS and HTML, or are ...

How to Implement Double Click Functionality in VueJS

I am facing an issue with my table where the columns have varying widths. To implement sticky headers, I need to calculate the column widths accurately. Initially, I created a function that increases the column width when double-clicking on the header. Su ...

Creating a recursive function using NodeJS

This particular challenge I am tackling is quite intricate. My objective is to develop a recursive function in NodeJS that can interact with the database to retrieve results. Based on the retrieved data, the function should then recursively call itself. F ...

The functionality to deselect multiple options in a select box is not functioning properly

There seems to be an issue with removing the selected attribute from the selected values in a jQuery multiselect box. The console is not showing any errors. You can view a working example here The problem lies in this code snippet: $("#mltyslct option ...

A peaceful WCF service initiates a client callback whenever a server update occurs

In the process of developing a WCF RESTFUL service on top of a c++ console application, I am confronted with an issue. The client accesses this c++ application through my restful wcf service using a browser. Every time there is an update received by my w ...

Generating examples of two models that are interdependent

In my Javascript form, I have implemented an AJAX POST request that successfully creates a new instance of a model called Component. Now, my goal is to allow users to input keywords for the Component model through the same form. To achieve this, I have al ...

The data insertion query in MYSQL seems to be malfunctioning

I am facing an issue with inserting data from a form into a database table named "sumation". Despite using PhpStorm IDE, I am getting errors indicating that no data sources are configured to run the SQL and the SQL dialect is not set up. Can anyone help ...

Understanding how to sum the values of two separate dropdown selections using jQuery

Is it possible to combine and total up two different selections to display on the "Total" button below? I have added calculations to each selection. When a user selects a quantity, it should automatically sum up and display on the "Total" button, but I am ...