Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Dot Net Cheat Sheet Cheat Sheet

by abyssmint via cheatography.com/156826/cs/33290/

Asynch​ronous JavaScript & XML (AJAX) jQuery (cont) Promises in JavaScript

Technique for accessing web servers from a getJSON() - method used to get JSON data usingRepresents
an the eventual completion of an
web page. AJAX HTTP GET request asynch​ronous operation and its resulting
Modifies only a portion of the displayed Syntax: value

page without the need to reload the whole $(selector).getJSON(url,data,success(data,status,xhr)


Examples of 3 methods for handling
document file Example: promises:
$.getJ​SON​("bo​ok.j​son, function -done()
Enables more intera​ctivity not possible in
(result)) {$("​#aa​a").h​tm​l(r​esu​lt.t​‐ -fail()
the tradit​ional web applic​ations using
synchr​onous request and response model
itle); -always()
append() - method to insert specified content at the
Partial Page Update Web API
end of the selected elements. Use prepend() to insert
content at the beginning. REST APIs
A mark up file (.cshtml) that renders HTML
Syntax: - Stands for REpresen​tat​ional State
output wihtin another markup file's rendered
$(selector).append(content) T ranswer
output
- Operats on HTTP reques​t/R​esponse
each() - method to iterate over DOM elements, arrays
In contro​ller: return​(Pa​rti​alView ("_v​iew​Pag​‐
and objects. Protocol
e", model());
Syntax HTTP Status Code
In .cshtml: <pa​rtial name = "​_vi​ewP​age​"
$(selector).each(function(index, value)) - Sucessful Responses: 200, 201
model = ("codes in here")
$.each(collection, functi​on(​index, value)) - Redire​ction Response: 301
serail​ize() - method to create a URL encoded text - Client Error: 400, 401, 403, 404
Web API
string by serial​izing form values. - Server Error: 500
REST APIs Syntax
- Stands for REpresen​tat​ional State $(selector).seralize() Web API
T ranswer
ajax() - method which provides core functi​onality ofREST APIs
- Operats on HTTP reques​t/R​esponse
AJAX - Stands for REpresen​tat​ional State
Protocol
Syntax: T ranswer
HTTP Status Code $.ajax(url) - Operats on HTTP reques​t/R​esponse
- Sucessful Responses: 200, 201 $.ajax(url, [options]) Protocol
- Redire​ction Response: 301
HTTP Status Code
- Client Error: 400, 401, 403, 404 Promises in JavaScript - Sucessful Responses: 200, 201
- Server Error: 500
Represents the eventual completion of an - Redire​ction Response: 301
API returning object with HTTP Status
asynch​ronous operation and its resulting - Client Error: 400, 401, 403, 404
- IActio​nResult return type like Web App
value - Server Error: 500
controller
Examples of 3 methods for handling
- Able to be return with HTTP response
promises:
status:
-done()
Ok(200)
-fail()
NotFound(404
-always()
BadRequest(400)
UnAuthorized(401)
JSON
Media Format Support in WEB API
- XML (eXten​sible Markup Language)
- JSON(J​ava​Script Object Notation)
- BSON(B​inary JSON)
Web API Routing
- Routing maps incoming requests to
specific controller and action
Example:
In ApiCon​tro​ller: [Route​("ap​i/(name of
contro​lle​r)")]
In Browser: http:/​/lo​cal​hos​t/a​pi/​con​troller
jQuery Data Types
- Number
load() - method is used to load data from a
- String
server and puts the returned data into the
- Boolean
selected element.
- Object
Syntax:
- Array
$(selector).load(URL)
- null
$(sele​cto​r).l​oa​d(URL, data, callback)
Objects
- JSON objects are dictionaries.
- Enclosed with curly brackets { }
- Keys and Values can be any data type
Arrays
- Arrays are Lists
- Enclosed with square brackets { }
- In between, a list of values separated by
commas.
- Each of which ma be of any type.

Nesting
- Nesting Involves putting arrays and
objects inside each other
- Arrays can be put inside objects, objects
inside arrays, and so on.
- A JSON file can be one BIG object with
lots of objects and arrays inside

By abyssmint Not published yet. Sponsored by CrosswordCheats.com


cheatography.com/abyssmint/ Last updated 21st July, 2022. Learn to solve cryptic crosswords!
Page 1 of 2. http://crosswordcheats.com

You might also like