How to Use Jquery_jquery-js in MVC applications tutorial

Source: Internet
Author: User
This article mainly introduces how to use Jquery In the MVC application, and attaches an example for reference by the partners who need it. In a twinkling of an eye, it was middle November, from today on, I will continue to study ASP. net mvc details usage, so I write these Reading Notes and personal experiences into a blog, so that everyone can learn things. My books are ASP. net mvc advanced programming, I will talk about how to use JavaScript and Jquery in MVC. We also use Ajax frequently.

1. Ajax preliminary introduction

(1) Currently, almost all Web applications we create use Ajax technology. In terms of technology, Ajax represents Asynchronous JavaScript and XML (Asynchronous JavaScript and XML, Ajax ). In practical applications, he represents all the technologies used to build responsive Web applications with good user experience.

(2) ASP. NET MVC4 is a modern Web framework. Like other modern Web frameworks, it supports Ajax technology from the very beginning. The core of Ajax support is the open-source JavaScript library Jquery.

(3) if we want to use Ajax in MVC, we need to learn about Jquery. Jquery is not the main topic of this blog, so I suggest you study it the same way if you have not learned it, my Jquery learning comes from "sharp Jquery".

2. How to Use Jquery in MVC applications

(1) When you use the Visual Studio Project template to create a new ASP. net mvc project, it will generate all content required by Jquery by default, each new project contains a Scripts folder, which contains many. js file. You can create a new mvc project ,:

   

(2) The JQuery core library is named Jquery- . Js file. Because the vs I use is 2012, the Jquery version is 1.7.1. This file contains the annotated version of JQuery source code. There is also a Jquery- . Min. javaScript files. Simplified JavaScript files include ". min ", as the name suggests, they occupy less space than the corresponding non-streamlined files (usually half the space ). They do not contain unnecessary white spaces or comments, and the length of all local variable names is one character. If you open a simplified file, you will see a bunch of unreadable JavaScript code. :

      

(2) The behavior and implementation functions of a simplified JavaScript script file on the client are the same as those of a non-streamlined file. However, because the streamlined file is small, therefore, it is usually possible to send Thin files to the client as much as possible (because it can reduce the number of downloaded data bytes, thus speeding up loading and running ).

(3) Try the default Layout (_ Layout. cshtml) in ASP. net mvc applications to reference Jquery's simplified version with the following script tag:

    

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.