CSE 300 Software Engineering CSE 300 CSE 300

  • Slides: 6
Download presentation
CSE 300 - Software Engineering CSE 300

CSE 300 - Software Engineering CSE 300

CSE 300 - Software Engineering Discussion Items • Recap Javascript functions • Ajax in

CSE 300 - Software Engineering Discussion Items • Recap Javascript functions • Ajax in practice 2 by Manish Shrotriya

CSE 300 - Software Engineering Javascript asynchronous calling • JS functions ▪ ▪ ▪

CSE 300 - Software Engineering Javascript asynchronous calling • JS functions ▪ ▪ ▪ ▪ Function declaration vs. function calling vs. function expression JS functions are objects of Function class Functions (except arrow functions) by default have a this object. We can supply which ‘this’ we would like the function to use at runtime. Arrow functions are always called with enclosing this. Functions are also constructors of class with the name same as function name. Function objects by default have prototype property. A prototype is a template of the object. ▪ Properties and methods declared on a prototype are available to every object having that prototype. 3 by Manish Shrotriya

CSE 300 - Software Engineering Ajax in Practice AJAX stands for Asynchronous Java. Script

CSE 300 - Software Engineering Ajax in Practice AJAX stands for Asynchronous Java. Script and XML One browser tab is run on one JS thread. XMLHttp. Request is sent to the server by the Javascript thread Generally the request is asynchronous, meaning thread will not wait for the response. Benefit? • Response will be processed in a callback. • Needs correct header types on request and response so that response is not processed by the browser. • • 4 by Manish Shrotriya

CSE 300 - Software Engineering Ajax in Practice • To submit forms using use

CSE 300 - Software Engineering Ajax in Practice • To submit forms using use button instead of submit. Collect form data in From. Data/Json object • Attach readystate watcher and send request. • Example: 5 by Manish Shrotriya

CSE 300 - Software Engineering JQuery in Practice • JQuery is a wrapper object

CSE 300 - Software Engineering JQuery in Practice • JQuery is a wrapper object over DOM objects and provides cross browser compatible, easy and uniform manipulation capability. • $() or JQuery() is a selector function that allows to retrieve desired DOM objects in an array based on selection criteria. • $. functions are static, stand alone utility functions like: ▪ $. each is used to iterate over an array. ▪ $. get is used to send get Ajax request ▪ $. load appends a given html under the selected html elements. 6 by Manish Shrotriya