ASP. NET MVC Ajax passes values to the background and puts back JSON value resolution

Source: Internet
Author: User


What is AJAX?

AJAX = asynchronous JavaScript and XML.

AJAX is a technique for creating fast, Dynamic Web pages.

AJAX enables Web pages to be updated asynchronously by exchanging small amounts of data in the background with the server. This means that you can update a part of a webpage without reloading the entire page.

Traditional Web pages (without AJAX) if you need to update the content, you must reload the entire page surface.

There are many examples of applications that use AJAX: Sina Weibo, Google maps, happy net, and more.

Ajax defines a usage reference http://www.w3school.com.cn/jquery/ajax_ajax.asp jquery Ajax Ajax Method

Ajax foreground calls:

 $.ajax ({url: "/manage/getcard", type: ' Post ', data: {"Labl": LA                    BL, "LabA": LabA, "Labb": Labb, "state": State, "CONFIG1": Config1, "Config2": Config2, "Config3": Config3},                        Success:function (data) {//Sent after the successful return of data, after the execution success://alert (data[0].cd_id);                        alert (data.length);   for (var i = 0; i < data.length; i++)                         {                            var GB = Data[i ].cd_rgb;                            var id = null;& nbsp                           data[i].cd_id;  = &nbsp ;                         $ ('.Color_list '). Append (' <div id= ' resultcolor ' class= ' resultcolor ' cd_id= ' + data[i].cd_id        & nbsp                       + ' style= ' width:100%; height:200px;backgroun D-color: ' + GB + '; margin-bottom:20px; "                    ></div> ');               $ (". Resultcolor:eq (" + i + ")"). Click (function () {      & nbsp                                var a = $ (this). attr ("cd_id"); }}

Receive and put back JSON in the background:

Public ActionResult Getlab (string tb_rgbr, String tb_rgbg, String tb_rgbb)        {                      var Resultjson = new {                L = Tb_lab L,                A = Tb_laba,                B = Tb_labb            };            Return Json (Resultjson);        }


ASP. NET MVC Ajax passes values to the background and puts back JSON value resolution

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.