Dealing with Jquery ajax errors in Internet Explorer

Trying to implement an ajax call:

var sourceUrl = ' http://api.official.fm/tracks/D4lw?fields=streaming,cover&api_version=2';

 jQuery.ajax({
    url: sourceUrl,
    dataType: 'jsonp',
 }).done(function( response ) {
 }).fail(function(jqXHR, textStatus, errorThrown) {
    if(useAlertMessaging) alert('error: ' + jqXHR.responseText);
 });

The code runs smoothly in IE10, however, encounters an error in IE9 and below:

SCRIPT1004: Expected ';' 
D4lw, line 1 character 9

The console displays the following information:

{"track":{"title":"Love Me As I Have Loved You (prod. Ritz Reynolds)","duration":75,"artist":"Mac Miller","url":"http://api.official.fm/tracks/D4lw?api_version=2","page":"http://official.fm/tracks/D4lw","buy_url":null,"rough_view_count":null,"rough_play_count":null,"rough_download_count":null,"streaming":{"http":"http://api.official.fm/tracks/D4lw/stream?api_version=2","rtmp":"rtmpe://fairtilize-174.fcod.llnwd.net/a2251/r2/mp3:/audio2/s/D4/D4lw_3594640?e=1378301197&h=8a551f822a7fbbc6fe07866626451bc3"},"cover":{"urls":{"large":"//cdn.official.fm/medias/pictures/tu/tuKi_large.jpg","medium":"//cdn.official.fm/medias/pictures/tu/tuKi_medium.jpg","small":"//cdn.official.fm/medias/pictures/tu/tuKi_small.jpg","tiny":"//cdn.official.fm/medias/pictures/tu/tuKi_tiny.jpg"},"id":"tuKi"},"project":{"name":"Mac Miller","url":"http://api.official.fm/projects/f8w6?api_version=2"}}}

The issue seems to be right before the first track semicolon:

{"track"

Any suggestions on how to resolve this?

(Note: No control over the URL used)

Tried removing ajax dataType but no change in results.

Answer â„–1

In my experience, I've encountered issues with inserting an additional comma into objects specifically when using IE. Here is a revised version of the code to address this problem:

jQuery.ajax({
    url: url,
    dataType: 'jsonp' // The extra comma has been removed from this line
 }).done(function( data ) {
    //console.log(data);
 }).fail(function(jqXHR, textStatus, errorThrown) {
    if(useAlertMessaging) alert('error: ' + jqXHR.responseText);
 });

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 contents of the Xml file are not appearing correctly in the list when viewed on Wamp

Recently, I delved into the realm of Ajax methods after browsing through W3schools and attempting to incorporate their teachings from a video tutorial. The specific video can be found at: After coding and placing the necessary files in the www directory o ...

Struggling to display AJAX GET results on my webpage, although they are visible in the Google Element Inspector

I'm working on a basic invoice page where I need to populate a dropdown box from my MySQL database. The issue I'm facing is that when I select an item, the description box doesn't get prepopulated as expected. I've checked in the networ ...

Updating Jqplot display upon ajax call completion

Currently, I have a Jqplot set up using the AJAX JSON Data Renderer and it's functioning properly. There is a button on the page where users can input new values (updated through ajax) which are then stored in the same DB as the json data source. Whe ...

What is the best method to extract information from JSON files that begin with a curly brace "{ "?

I am utilizing the themovieDB API to parse a JSON. The JSON begins with { so it lacks any root or if it does have one, I am unsure how to reference it in Swift. When I attempt to parse it with a root that I created, it throws this error: "keyNotFoun ...

JavaScript having trouble parsing JSON, despite Chrome console being able to parse it flawlessly

I've hit a roadblock while attempting to retrieve coordinates from a database for the Google Maps API in order to create a polygon. First, I fetch my data from the database using Laravel Framework: MapController - public function getallmapcoords(re ...

Using JQuery and AJAX, transfer information to the file input element

Currently, I am utilizing a JQuery library to crop images. Once the user clicks on the crop button, the cropped image (result) is sent back to the HTML page via AJAX as "file data". An example of this file data format is: data:image/png;base64,iVBORw0KGgo ...

The Spring REST response displays the unprocessed Java object instead of the expected JSON components

Within my Spring application, there is an Object called FooBar. When a request is made to an endpoint, the REST service returns this object in the following format: { "item":"foo", "value":"bar" } Recently, I created another Object named FooBarMap that c ...

What is the most effective way to perform two GET requests in PHP?

Here's the code snippet I am currently working on: $header = [ 'phoneType' => $mobileType ]; \Drupal::logger("cam")->debug('PageNameHere retrieveAPINameHere REQUEST: '.json_encode($head ...

Is it possible to utilize $.getJSON() with a machine on the identical subdomain?

My server is called mybox.ourcorp.ourdomain.com. I am attempting to make a JSON request from this server to another server within the same subdomain, specifically http://otherbox.ourcorp.ourdomain.com/feed. When I manually enter this URL in a browser on m ...

How to avoid mistakes with GSon in Java (avoiding null pointer exceptions)

I'm attempting to extract the number of search results from a Google query string. public class Utils { public static int getGoogleHits(String query) throws IOException { String googleAjax = "http://ajax.googleapis.com/ajax/services/sear ...

Having difficulty with the searchTextField in Swift 5 while attempting to search for city, state, and country details simultaneously

I am facing a challenge with updating the city label, state label, and country label when I enter the corresponding information in the search bar. Below is the code snippet for the searchPressed action: extension AirQualityViewController: UITextFieldDeleg ...

Widget class with an AJAX function

I designed a custom WordPress Widget that fetches the latest posts. Initially, it retrieves a specific number of posts and provides a button for users to load more posts through AJAX. Here is the complete code for the Widget: /* recent posts Widget ==== ...

Encountering an error with an undefined property while trying to extract information from a JSON string

Here is the JSON string I have: { "data": [ { "id": "533513150124231", "created_time": "2015-02-27T05:23:02+0000", ... }, { "id": "533911933417686", "created_time": "2015-02-28T07:18:09+0000", ... }, { "id": "533471226795090", "created_tim ...

Encoding special characters

When working with JSON to exchange data between systems, I often encounter rich text properties. While most of the time everything goes smoothly, occasionally special characters like curly quotes that are not in UTF-8 format slip into the text. I am looki ...

What is the process for retrieving external JSON using PHP with a content-type of text/plain?

I am attempting to retrieve an external JSON response using my PHP backend. However, I am encountering an issue where the external endpoint is returned with the Content-Type: text/plain;charset=utf-8, resulting in unreadable content. string 'ï¿½ï¿½ï¿ ...

Using PHP in conjunction with DataTables results in an error with JSON responses caused by quotation marks

In the process of fetching data from my database and displaying it via DataTables, I ran into an issue. It seems that the presence of single and double quotes along with other special characters in most of my data is causing problems. Despite trying variou ...

How can I implement file downloads from an AJAX response using CodeIgniter and PHPExcel?

Struggling to achieve my goal and unsure if it's possible. Using CodeIgniter and PHP for a web application. Home view allows users to query a database with results displayed in a table on the page, with an option to download as an xlsx Excel file. Use ...

Does Postgres have a similar feature to SQL Server's Open from rowset command that allows importing JSON files?

We are currently transferring code from a SQL Server database to a Postgres v16 database There is a sample file named 'temprj.json' with the following structure: temprj.json { "ChannelReadings": [ { "ReadingsDto": [ ...

The autocomplete feature is not displaying the suggested text at the top when choosing data

Recently started using react native and I'm currently working on implementing an AutoCompleteTextView. I have a json file that contains country names which need to be displayed in the autocomplete view. Although I am able to display the names of all c ...

Performing asynchronous ajax calls with jQuery

Here is some code I have that involves a list and making an ajax call for each element in the list: util.testMethod = function(list) { var map = new Map(); list.forEach(function(data) { $.ajax({ ...