Fix Deprecated: jQuery.parseJSON() warning by updating to JSON.parse()

The jQuery.parseJSON() method has been deprecated since jQuery 3.0, and
generates a warning in the console. This patch replaces all instances of
jQuery.parseJSON() with JSON.parse(), as recommended in the jQuery
upgrade guide [1]. This ensures that the code is compatible with the
latest version of jQuery and eliminates the warning.

[1] https://jquery.com/upgrade-guide/3.0/#deprecated-jquery-parsejson
Change-Id: I1da5a6c56cefe9bbe0c1185ac8c536eb8f2a6a35
This commit is contained in:
manchandavishal 2023-04-10 18:36:41 +05:30 committed by Vishal Manchanda
parent 7d44796eca
commit de61e2a049
4 changed files with 4 additions and 4 deletions

View File

@ -93,7 +93,7 @@ horizon.autoDismissAlert = function ($alert) {
horizon.addInitFunction(function () { horizon.addInitFunction(function () {
// Bind AJAX message handling. // Bind AJAX message handling.
$(document).ajaxComplete(function(event, request){ $(document).ajaxComplete(function(event, request){
var message_array = $.parseJSON(horizon.ajax.get_messages(request)); var message_array = JSON.parse(horizon.ajax.get_messages(request));
$(message_array).each(function (index, item) { $(message_array).each(function (index, item) {
horizon.alert(item[0], item[1], item[2]); horizon.alert(item[0], item[1], item[2]);
}); });

View File

@ -346,7 +346,7 @@ horizon.addInitFunction(horizon.modals.init = function() {
} else if (redirect_header) { } else if (redirect_header) {
location.href = redirect_header; location.href = redirect_header;
} else if (add_to_field_header) { } else if (add_to_field_header) {
json_data = $.parseJSON(data); json_data = JSON.parse(data);
field_to_update = $("#" + add_to_field_header); field_to_update = $("#" + add_to_field_header);
field_to_update.append("<option value='" + json_data[0] + "'>" + json_data[1] + "</option>"); field_to_update.append("<option value='" + json_data[0] + "'>" + json_data[1] + "</option>");
field_to_update.change(); field_to_update.change();

View File

@ -157,7 +157,7 @@ horizon.network_topology = {
self.translate = null; self.translate = null;
}); });
angular.element(window).on('message', function(e) { angular.element(window).on('message', function(e) {
var message = angular.element.parseJSON(e.originalEvent.data); var message = JSON.parse(e.originalEvent.data);
if (self.previous_message !== message.message) { if (self.previous_message !== message.message) {
horizon.alert(message.type, message.message); horizon.alert(message.type, message.message);
self.previous_message = message.message; self.previous_message = message.message;

View File

@ -88,7 +88,7 @@ horizon.networktopologymessager = {
// listens for message events // listens for message events
angular.element(window).on('message', function(e) { angular.element(window).on('message', function(e) {
var message = angular.element.parseJSON(e.originalEvent.data); var message = JSON.parse(e.originalEvent.data);
if (self.previous_message !== message.message) { if (self.previous_message !== message.message) {
horizon.toast.add(message.type, message.message); horizon.toast.add(message.type, message.message);
self.previous_message = message.message; self.previous_message = message.message;