"Trouble with making jQuery AJAX calls on Internet Explorer versions 8 and 9

I've been searching for the answer to this problem without any luck. I have a page with jquery ajax calls to an API service. It works well in Chrome, Safari, Firefox, and IE 10, but fails in IE 9 and 8.

Here is the code:

 $.ajax({
                    type: "GET",
                    url: "http://api.domain.org/api/campus?filtertype=name&filter="+ escape($('#campus').val()),
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function (result) {
                        $('#results').children().remove();
                        var arrayd = (typeof result) == 'string' ? eval('(' + result + ')') : result;
                        if (arrayd != null) {
                            for (var i = 0; i < arrayd.length; i++) {
                                $('#results').append('<li>' + arrayd[i].SchoolName + '</li>');
                            }
                        }
                    },
                    error: function (request, status, errorThrown) {
                        alert("There was an issue with the request");
                    } // When Service call fails
                });

The main issue is that the alert pops up, but there is no traffic shown in the IE Debugging tools, making it difficult to determine if the server is being reached.

I've attempted several solutions:

  1. Adjusting $.ajax settings as mentioned in this article
  2. Setting '$.support.cors = true;' before making the ajax call
  3. Using 'jquery.iecors.js'

Update:

After changing the dataType to 'jsonp', I can now see traffic in IE 8/9 with successful calls. However, the success method isn't being triggered in any browser.

 $.ajax({
                    type: "GET",
                    url: "http://api.athletesinaction.org/api/campus?filtertype=name&filter="+ escape($('#campus').val()),
                    dataType: "jsonp",
                    async: false,
                    contentType: "application/javascript",
                    crossDomain: true,
                    jsonpCallback: 'myTest',
                    success: myTest,
                    error: function (request, status, errorThrown) {
                        alert(errorThrown);
                    } // When Service call fails
                });


        function myTest (argument) {
            alert("YEAH");
            $('#results').children().remove();
            var arrayd = (typeof result) == 'string' ? eval('(' + result + ')') : result;
            if (arrayd != null) {
                for (var i = 0; i < arrayd.length; i++) {
                    $('#results').append('<li>' + arrayd[i].SchoolName + '</li>');
                }
            }
        }

Answer №1

Consider switching the dataType to jsonp.

Make sure that the service is compatible with this type of request.

Answer №2

Unfortunately, it does not function properly in IE8.

To ensure compatibility with IE8, consider using JSONP, postMessage, or a combination of both methods.

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

The expiration time and date for Express Session are being inaccurately configured

I'm experiencing an issue with my express session configuration. I have set the maxAge to be 1 hour from the current time. app.use( session({ secret: 'ASecretValue', saveUninitialized: false, resave: false, cookie: { secure ...

How to refresh a specific component or page in Angular without causing the entire page to reload

Is there a way to make the selected file visible without having to reload the entire page? I want to find a cleaner method for displaying the uploaded document. public onFileSelected(event): void { console.log(this.fileId) const file = event.targe ...

Displaying content on a webpage using PHP, AJAX, and HTML

Looking to update my current form setup. I have a basic Form below: <form action="" method="POST"> <input type="button" value="Generate Numbers" onclick="on_callPhp1()"/> </form> Accompanied by this javascript code: <script type="te ...

Modify the anchor text when a malfunction occurs upon clicking

Whenever I click on the link, I am able to retrieve the correct id, but the status changes for all posts instead of just the selected item. Below is the HTML code: <div th:each="p : ${posts}"> <div id="para"> <a style="float: right;" href= ...

Include a Vue component within another Vue component in a Laravel application using VueJs

I've recently integrated Vue.js into my Laravel project and encountered an issue when trying to call a component within another component. After running the command npm run dev, I received a webpack error. Here is the code snippet from my parent comp ...

Spread the picture on social media using Progressive Web App

I am currently working on a Nuxt PWA where I have implemented a function to convert HTML to Canvas using a specific package. The output generated is in base 64 format. My goal now is to find a way to easily share this image through various platforms such a ...

Conceal the div class upon clicking it

I'm dealing with a list of videos and I need to hide the class when it's clicked. Check out this sample HTML output: <div id="primary-video"> <iframe id="video" width="100%" height="auto" src="https://www.youtube.com/embed/test" fra ...

Node JS: Despite modifying the URL, the response remains unchanged

My attempt to log in to teeSpring.com and retrieve a response from another URL using a login cookie seems to be causing an issue. Upon logging into teeSpring.com, the dashboard details are returned. However, when I try to make a GET request to the second U ...

Is there a way for me to dynamically decide whether to use the append or prepend function?

Utilizing jQuery to retrieve data from the controller and populate a calendar represented by a table with days in columns. Implementing functionality for navigating between previous week / next week, as well as previous day / next day. The four scenarios s ...

What is the best way to align a series of divs vertically within columns?

Struggling to find the right words to ask this question has made it difficult for me to locate relevant search results. However, I believe a picture is worth a thousand words so...https://i.stack.imgur.com/LfPMO.png I am looking to create multiple columns ...

This asynchronous function will provide a response of "undefined"

Having a challenge with an async function that should return a geocode value: async function getLocationCoordinates(place){ //var str; return googleMapsClient.geocode({ address: place }).asPromise() .then((response) => { response.json.results[0].ge ...

CSS - Make the entire div clickable while leaving a specific area non-clickable

I have a block containing some information. Within this div is a hidden button labeled .remove. Clicking on the main block will take you to another page, while hovering over the div will reveal the button. However, clicking the button also navigates you aw ...

Swapping out LinkButtons using jQuery

[EXPLANATION] (apologies for the length) In my gridview, users have the option to add a new entry or edit an existing one. When they click on either 'Add' or 'Edit', a popup window appears for them to input the information for the new ...

Automatically populate form fields with data from the clicked row in the HTML table when using JSP

Attempting to populate form fields using jQuery or JavaScript with row elements selected by clicking on the row. Tried a solution from Stack Overflow that didn't work as expected. I'm new to this, so please bear with me. (http://jsbin.com/rotuni/ ...

How can you create an ordered list with letters and parentheses using HTML5 and CSS?

Is it possible to use letters with ")" instead of "." in an ordered list format? For example: a) Some text... b) Some text... c) Some text... Currently, I am seeing: a.) Some text... b.) Some text... c.) Some text... I need to remove the periods. CSS: ...

What is the best way to align a checkbox and text in the same row within a Mailchimp embedded form?

I am troubleshooting a styling issue with my Mailchimp form that has groups. The problem I'm encountering is that the checkboxes are displaying on one line while the text appears on the next line in an unordered list format. To see the issue for yours ...

"Implementing a comment system using Node.js and MySQL: A comprehensive guide

Hey there! I have some data that I want to use to create a hierarchical data example. { id_commentForum: 1, id_user: 1, id_thread: 1, comment: 'This is the First Comment', parent: 0, created_at: Wed Jun 22 2016 13:36:38 G ...

Python Selenium error: NoSuchElementException - Unable to find the specified element

Coding Journey: With limited coding knowledge, I've attempted to learn through various resources without much success. Now, I'm taking a different approach by working on a project idea directly. The goal is to create a program that interacts wi ...

Implementing restriction measures for deterring harmful conduct within ExpressJS

Recently, I was alerted to some potential vulnerabilities in the application I'm currently developing, particularly in relation to the JavaScript code on the front-end. These flaws could allow a user to exploit the system by clicking multiple buttons ...

searchByTextContentUnderListItemAnchorTag

I would like to utilize the getByRole function for writing my test. However, I am encountering issues when using linkitem or 'link' as the role. It seems that I cannot find the desired element. // encountered error TestingLibraryElementError: The ...