Asp.net works with easyui to return json data instances

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.