Node. js and jQuery UI autocomplete

Source: Internet
Author: User
Tags jquery ui autocomplete

Areas of expertise in Node. js are:

  • Does not require many operations
  • High throughput requirements
  • Lightweight and fast incoming messages
  • Low outgoing message and fast request

The online examples are socket. io. I have been wondering where I can use it? Based on the advantages of node. js (fields of expertise), I came up with this application scenario:

In the autocomplete Application Scenario of jQuery UI, the required data is fragmented but large.

The structure is as follows:

  • Use ASP. NET MVC4 to create a web site. Compile jQuery UI autocomplete code here
  • Use WebMatrix to write Node. js Code (mainly express-based routing)

Because these two sites are independent, cross-domain issues are involved. Use JSONP to solve the problem. (In fact, You must modify the corresponding code in both js Code calls and node. js ).

Post ASP. NET MVC4 code first

                                                  dataType:                                        );                          },                          error:      

 

Then, create the Node. js program and check the new Node. js Dialog in WebMatrix:

After the new file is created, you will see a bunch of files have been created. first look at the server. js entry file and then look at the route file:

 express = require('express'  , http = require('http'  , path = require('path'  , routes4users = require('./routes/users' app ='port', process.env.PORT || 3000'views', __dirname + '/views'  app.set('view engine', 'jade'  app.use(express.favicon());  app.use(express.logger('dev''development', '/users/:name'
'port'), "Express server listening on port " + app.get('port'

 

Look at the users. js file:

.UserName = .Age = -1 users =  ( i = 0; i < 10; i++ u== "aaron" +==  searchKey = result =  ( i = 0; i < users.length; i++ (users[i].UserName.indexOf(searchKey) >= 0 callbackFunctionName =    res.setHeader('Content-Type', 'application/javascript; charset=utf-8' str == callbackFunctionName+"(" + str + ")"    res.send(str);}

 

Run:

 

 

 

 

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.