Asp.net works with easyui to return json data instances
Recently I want to use asp.net to develop a small framework with easyui, and then use easyui's combobox. A problem occurs. In general, the format of combobox provided in easyui documents is
The Code is as follows:
<Input class = "easyui-combobox"
Name = "language"
Data-options ="
Url: '../combobox/combobox_data1.json ',
ValueField: 'id ',
TextField: 'text ',
Multiple: true,
PanelHeight: 'auto'
">
At first, I wanted to use asp.net's Weibo [Method] Method in combination with ajax to write data. However, this caused a problem. The ajax Method using [Method] is in the following format,
The Code is as follows:
$. Ajax ({
Type: "post ",
Url: "addBug. aspx/GetVersions ",
Data: "{'producename': '" + selectedValue + "'}",
DataType: "json ",
ContentType: "application/json; charset = UTF-8 ",
Success: function (data ){
$ ("# Versions"). empty ();
$ ("# Versions"). append (data. d );
}
});
That is to say, it is necessary to write its contentType, but this does not exist for the data-options parameter of easyui Combobox. In this way, a large number of HTML statements are contained in the returned results, which has been entangled for a long time, later, I tried it accidentally. the ashx file was successful.
Later, I checked the role of the. ashx file. Simply put, it provides the function of returning strings and images, instead of returning processing results and a large number of HTML files like the. aspx file.