SoFunction
Updated on 2025-04-12

Solution to the problem with $.getJSON under ie

Prerequisite: Related js files need to be imported

$.post(url,data,success(data, textStatus, jqXHR),dataType)

url: Required. Specifies which URL to send the request.

data: optional. Map or string value. Specifies the data sent to the server together with the request.

success(data, textStatus, jqXHR): optional. A callback function executed when the request is successful.

dataType: Perform intelligent judgments (xml, json, script or html) by default.

$.getJSON(url,data,success(data, textStatus, xhr))

url: Required. Specifies which URL to send to the request.

data: optional. Specifies the data sent to the server together with the request.

success(data,status,xhr):

Optional. Specifies the function to run when the request is successful.

Additional parameters:

response - contains result data from the request
status - contains the status of the request
xhr - Contains XMLHttpRequest object

Extension is written as:
Copy the codeThe code is as follows:

$.ajax({

type:'POST' or 'GET',

url:url,

data:data,

success:callback,

dataType:json

});

DataType has these types: xml, json, script or html

Notice:

When using the $.getJson method, if there are Chinese characters passed into the url, you need to escape first (if you do not escape, $_GET['v'] will not get the value under ie8, and other browsers will not have this problem)

eg:

var url = "/?op=product&v="+encodeURIComponent('Study hard');