SlideShare a Scribd company logo
1 of 137
Javascript + jQuery: With great power, comes great responsibility http://www.slideshare.net/ciberglo/scti-2011-minicurso-jquery Gabriel Lima @glima5 github.com/gabriellima
 
 
 
Balanceando: Básicos ,[object Object]
typeof(0) == "number" ,[object Object],[object Object]
if ( 4 && !0 && "test" && !"" && !undefined && { } ){
alert("true");
}
Balanceando: Funções
Balanceando: Objetos ,[object Object]
var shape = new Shape();
var obj = { };  // Object literal, == "new Object()"
var arr = [ ];  // Array literal, == "new Array()"
var exp = /[0-9a-z]/ig;  // reg exp literal
Balanceando: Hashes ,[object Object]
var lastNames = { };
lastNames["Jason"] = "Horton";
lastNames["Matheu"] = "Chambers";
lastNames["Rohit"] = "Mistry";
for ( var key in lastNames ) {
alert( key + " " + lastNames[key] );
}
Exemplo: Array sorting ,[object Object]
Exemplo: Array sorting ,[object Object]
// retorna ["a", "A", "b", "f", "o", "x", "Z"]  ... mais útil
Scope var iAmGlobal = 5 * 5; function doSomething() { var inner = 5 * 5; }; var g = "global"; function go() { var l = "local"; } go(); console.log(l); // throws a reference error
Scope: How it works function go() { console.debug(this); } go(); var myObject = { go: function() { console.debug(this); } }; myObject.go(); // console.debugs a reference to myObject
Scope: How it works function MyClass() { this.go = function() { console.debug(this); } }; var instance1 = new MyClass(); var instance2 = new MyClass(); instance1.go(); // console.debugs a reference to the MyClass instance1 instance2.go(); // console.debugs a reference to the MyClass instance2
Qual o lugar do javascript? ,[object Object]
Todo o resto deve ser deixado pra tecnologia que temos pra fazer o serviço.
 
Progressive enhancement ,[object Object]
Web Site – Web Browser ?
Não!
Web Browser – Web Page
Televisão – Show de música
Sim!
 
Progressive enhancement 2.0
Progressive enhancement 2.0 ,[object Object]
Progressive enhancement 2.0 ,[object Object]
Progressive enhancement 2.0 ,[object Object]
Progressive enhancement 2.0 ,[object Object]
Progressive enhancement 2.0 ,[object Object]
Melhor experiência de acordo com capacidade do dispositivo
[object Object]
Script avançado e comportamentos -> somente com APIs javascript nativas
Navegadores antigos quase sempre precisam de  muito mais  código pra fazer a mesma coisa!
 
 
[object Object]
 
[object Object]
 
 
Você não está sozinho
Keep javascript out of HTML ,[object Object]
<button id='do_search'>better!</button>
(function(){   var search_button = document.getElementById('do_search');   search_button.onclick = function(event) {   do_something();   } })();
HTML vs Javascript ,[object Object]
Se você percebe que está digitando muito código HTML num codigo javascript, você deve estar fazendo algo errado
Keep HTML out of Javascript ,[object Object]
Keep Javascript out of CSS ,[object Object]
Keep CSS out of Javascript ,[object Object]
Exemplo: borda vermelha ,[object Object]
Exemplo: borda vermelha
Exemplo: borda vermelha
Event handlers should only handle events //the wrong way!!! function handleClick(event){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = event.clientX + &quot;px&quot;; popup.style.top = event.clientY + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
Don't pass the event object around //better, but still wrong function handleClick(event){ showPopup(event); } function showPopup(event){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = event.clientX + &quot;px&quot;; popup.style.top = event.clientY + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
Separe corretamente os event handlings //fuck yeah!! function handleClick(event){ showPopup(event.clientX, event.clientY); } function showPopup(x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
Avoid global functions and variables function handleClick(event){ showPopup(event.clientX, event.clientY); } function showPopup(x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
Create a single global (se necessário) var Controller = { handleClick: function(event){ this.showPopup(event.clientX, event.clientY); }, showPopup: function (x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; } };
Separe configurações function validate(value) { if (!value) { alert(&quot;Invalid value&quot;); location.href = &quot;/errors/invalid.php&quot;; } };
Separe configurações var config = { urls: { invalid: &quot;/errors/invalid.php&quot; }, strs: { invalidmsg: &quot;Invalid value&quot; } }; function validate(value) { if (!value) { alert(config.strs.invalidmsg); location.href = config.urls.invalid; } };
Separe configurações ,[object Object]
Qualquer texto exibido para o usuário
Qualquer HTML que precisa ser criado pelo javascript
Configurações (exemplo: itens por página)
Valores únicos repetidos
Qualquer coisa que talvez seja modificada no futuro, e utilizada em mais de um lugar
Otimizando Loops: var names = ['George','Ringo','Paul','John']; for(var i=0;i<names.length;i++){ doSomeThingWith(names[i]); } var names = ['George','Ringo','Paul','John']; var all = names.length; for(var i=0;i<all;i++){ doSomeThingWith(names[i]); }
var names = ['George','Ringo','Paul','John']; for(var i=0,j=names.length;i<j;i++){ doSomeThingWith(names[i]); } ,[object Object]
Isso inclui expressões regulares, mas primeiro e mais importante: DOM manipulation (CAUTION!)
Você pode criar nós do DOM no loop, mas evitar sua inserção no documento
Repaint vs Reflow
Repaint ,[object Object]
- Mark 'Tarquin' Wilton-Jones, Opera
When Repaint? ,[object Object]
Formatting style changes ,[object Object]
Borders
Colors
Anything that doesn't change the size, shape or position of element but change appearance ,[object Object]
Reflow ,[object Object]
- Chris Waterson, Mozilla
When Reflow? ,[object Object]
Browser window resize
DOM nodes added or removed
Layout styles applied
Layout information retrieved
O que fazer? ,[object Object]
Agrupar modificações de estilos
Cachear informações de layout
 
Off-Document operations ,[object Object]
Técnica: ,[object Object]
Medium: Colocar 'display' do elemento como 'none', aplicar modificações, colocar 'display' volta ao padrão
Fuck yeah!: Construir modificações do DOM num 'DocumentFragment' e depois aplicar tudo de uma vez
DocumentFragment ,[object Object]
Não tem representação visual
Seu pai é o document que o gerou
Quando passado para 'appendChild()', adiciona todos seus filhos ao invés de si próprio
 
[object Object]
Agrupar modificações de estilos
Cachear informações de layout
 
O que fazer? ,[object Object]
Definir a classe CSS com todas modificações e então apenas modificar a propriedade 'className'
Definir diretamente o 'cssText' no elemento
 
 
[object Object]
Agrupar modificações de estilos
Cachear informações de layout ,[object Object]
 
O que fazer? ,[object Object]
Se um valor é usado mais de uma vez, armazene-o em uma variável local
Responsive UI Interface ,[object Object]
[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]

More Related Content

What's hot

"Writing Maintainable JavaScript". Jon Bretman, Badoo
"Writing Maintainable JavaScript". Jon Bretman, Badoo"Writing Maintainable JavaScript". Jon Bretman, Badoo
"Writing Maintainable JavaScript". Jon Bretman, BadooYandex
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016Nicolás Bouhid
 
Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)James Titcumb
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To PracticeSergey Bolshchikov
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important PartsSergey Bolshchikov
 
Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)James Titcumb
 
Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)James Titcumb
 
How to identify bad third parties on your page
How to identify bad third parties on your pageHow to identify bad third parties on your page
How to identify bad third parties on your pageCharles Vazac
 
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)James Titcumb
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
the 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp IIthe 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp IIDirk Ginader
 
Turn your spaghetti code into ravioli with JavaScript modules
Turn your spaghetti code into ravioli with JavaScript modulesTurn your spaghetti code into ravioli with JavaScript modules
Turn your spaghetti code into ravioli with JavaScript modulesjerryorr
 
RubyMotion
RubyMotionRubyMotion
RubyMotionMark
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryRefresh Events
 

What's hot (17)

"Writing Maintainable JavaScript". Jon Bretman, Badoo
"Writing Maintainable JavaScript". Jon Bretman, Badoo"Writing Maintainable JavaScript". Jon Bretman, Badoo
"Writing Maintainable JavaScript". Jon Bretman, Badoo
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
 
Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To Practice
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
 
Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)
 
Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)
 
How to identify bad third parties on your page
How to identify bad third parties on your pageHow to identify bad third parties on your page
How to identify bad third parties on your page
 
JavaScript Needn't Hurt!
JavaScript Needn't Hurt!JavaScript Needn't Hurt!
JavaScript Needn't Hurt!
 
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
JavaScript
JavaScriptJavaScript
JavaScript
 
the 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp IIthe 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp II
 
Turn your spaghetti code into ravioli with JavaScript modules
Turn your spaghetti code into ravioli with JavaScript modulesTurn your spaghetti code into ravioli with JavaScript modules
Turn your spaghetti code into ravioli with JavaScript modules
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQuery
 

Viewers also liked

"El Principe" Maquiavelo
"El Principe" Maquiavelo"El Principe" Maquiavelo
"El Principe" Maquiavelolichix99
 
Presentacion de como acceder a un curso en moodle
Presentacion de como acceder a un curso en  moodle Presentacion de como acceder a un curso en  moodle
Presentacion de como acceder a un curso en moodle Familia Botello Hermosa
 
Christman j making_the_most_of_interim_assessment_data
Christman j making_the_most_of_interim_assessment_dataChristman j making_the_most_of_interim_assessment_data
Christman j making_the_most_of_interim_assessment_datagnonewleaders
 
Mays prep the roundtable issue v (the year-in-review)
Mays prep the roundtable issue v (the year-in-review)Mays prep the roundtable issue v (the year-in-review)
Mays prep the roundtable issue v (the year-in-review)gnonewleaders
 
I leap leap 7-12 power point presentation
I leap   leap 7-12 power point presentationI leap   leap 7-12 power point presentation
I leap leap 7-12 power point presentationgnonewleaders
 
Kim marshall nola time man june 30,2010
Kim marshall nola time man june 30,2010Kim marshall nola time man june 30,2010
Kim marshall nola time man june 30,2010gnonewleaders
 
Medard h. nelson walkthrough observation notes
Medard h. nelson walkthrough observation notesMedard h. nelson walkthrough observation notes
Medard h. nelson walkthrough observation notesgnonewleaders
 

Viewers also liked (9)

La legalizacion de la prostitucion
La legalizacion de la prostitucionLa legalizacion de la prostitucion
La legalizacion de la prostitucion
 
"El Principe" Maquiavelo
"El Principe" Maquiavelo"El Principe" Maquiavelo
"El Principe" Maquiavelo
 
Presentacion de como acceder a un curso en moodle
Presentacion de como acceder a un curso en  moodle Presentacion de como acceder a un curso en  moodle
Presentacion de como acceder a un curso en moodle
 
Christman j making_the_most_of_interim_assessment_data
Christman j making_the_most_of_interim_assessment_dataChristman j making_the_most_of_interim_assessment_data
Christman j making_the_most_of_interim_assessment_data
 
Mays prep the roundtable issue v (the year-in-review)
Mays prep the roundtable issue v (the year-in-review)Mays prep the roundtable issue v (the year-in-review)
Mays prep the roundtable issue v (the year-in-review)
 
I leap leap 7-12 power point presentation
I leap   leap 7-12 power point presentationI leap   leap 7-12 power point presentation
I leap leap 7-12 power point presentation
 
Eagle faq
Eagle faqEagle faq
Eagle faq
 
Kim marshall nola time man june 30,2010
Kim marshall nola time man june 30,2010Kim marshall nola time man june 30,2010
Kim marshall nola time man june 30,2010
 
Medard h. nelson walkthrough observation notes
Medard h. nelson walkthrough observation notesMedard h. nelson walkthrough observation notes
Medard h. nelson walkthrough observation notes
 

Similar to Scti 2011 minicurso jquery

Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2tonvanbart
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS FrameworkMohd Imran
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWRSweNz FixEd
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2borkweb
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]Chris Toohey
 
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasFrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasLoiane Groner
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
jQuery for Sharepoint Dev
jQuery for Sharepoint DevjQuery for Sharepoint Dev
jQuery for Sharepoint DevZeddy Iskandar
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼Sukjoon Kim
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and DashboardsAtlassian
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlightKris van der Mast
 
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQueryBeing a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQueryKris van der Mast
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 

Similar to Scti 2011 minicurso jquery (20)

Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
 
Jquery 1
Jquery 1Jquery 1
Jquery 1
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS Framework
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWR
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
You Know WebOS
You Know WebOSYou Know WebOS
You Know WebOS
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
 
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasFrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
jQuery for Sharepoint Dev
jQuery for Sharepoint DevjQuery for Sharepoint Dev
jQuery for Sharepoint Dev
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
 
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQueryBeing a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 

Recently uploaded

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Scti 2011 minicurso jquery

  • 1. Javascript + jQuery: With great power, comes great responsibility http://www.slideshare.net/ciberglo/scti-2011-minicurso-jquery Gabriel Lima @glima5 github.com/gabriellima
  • 2.  
  • 3.  
  • 4.  
  • 5.
  • 6.
  • 7. if ( 4 && !0 && &quot;test&quot; && !&quot;&quot; && !undefined && { } ){
  • 9. }
  • 11.
  • 12. var shape = new Shape();
  • 13. var obj = { }; // Object literal, == &quot;new Object()&quot;
  • 14. var arr = [ ]; // Array literal, == &quot;new Array()&quot;
  • 15. var exp = /[0-9a-z]/ig; // reg exp literal
  • 16.
  • 21. for ( var key in lastNames ) {
  • 22. alert( key + &quot; &quot; + lastNames[key] );
  • 23. }
  • 24.
  • 25.
  • 26. // retorna [&quot;a&quot;, &quot;A&quot;, &quot;b&quot;, &quot;f&quot;, &quot;o&quot;, &quot;x&quot;, &quot;Z&quot;] ... mais útil
  • 27. Scope var iAmGlobal = 5 * 5; function doSomething() { var inner = 5 * 5; }; var g = &quot;global&quot;; function go() { var l = &quot;local&quot;; } go(); console.log(l); // throws a reference error
  • 28. Scope: How it works function go() { console.debug(this); } go(); var myObject = { go: function() { console.debug(this); } }; myObject.go(); // console.debugs a reference to myObject
  • 29. Scope: How it works function MyClass() { this.go = function() { console.debug(this); } }; var instance1 = new MyClass(); var instance2 = new MyClass(); instance1.go(); // console.debugs a reference to the MyClass instance1 instance2.go(); // console.debugs a reference to the MyClass instance2
  • 30.
  • 31. Todo o resto deve ser deixado pra tecnologia que temos pra fazer o serviço.
  • 32.  
  • 33.
  • 34. Web Site – Web Browser ?
  • 35. Não!
  • 36. Web Browser – Web Page
  • 37. Televisão – Show de música
  • 38. Sim!
  • 39.  
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46. Melhor experiência de acordo com capacidade do dispositivo
  • 47.
  • 48. Script avançado e comportamentos -> somente com APIs javascript nativas
  • 49. Navegadores antigos quase sempre precisam de muito mais código pra fazer a mesma coisa!
  • 50.  
  • 51.  
  • 52.
  • 53.  
  • 54.
  • 55.  
  • 56.  
  • 57. Você não está sozinho
  • 58.
  • 60. (function(){ var search_button = document.getElementById('do_search'); search_button.onclick = function(event) { do_something(); } })();
  • 61.
  • 62. Se você percebe que está digitando muito código HTML num codigo javascript, você deve estar fazendo algo errado
  • 63.
  • 64.
  • 65.
  • 66.
  • 69. Event handlers should only handle events //the wrong way!!! function handleClick(event){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = event.clientX + &quot;px&quot;; popup.style.top = event.clientY + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
  • 70. Don't pass the event object around //better, but still wrong function handleClick(event){ showPopup(event); } function showPopup(event){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = event.clientX + &quot;px&quot;; popup.style.top = event.clientY + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
  • 71. Separe corretamente os event handlings //fuck yeah!! function handleClick(event){ showPopup(event.clientX, event.clientY); } function showPopup(x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
  • 72. Avoid global functions and variables function handleClick(event){ showPopup(event.clientX, event.clientY); } function showPopup(x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; }
  • 73. Create a single global (se necessário) var Controller = { handleClick: function(event){ this.showPopup(event.clientX, event.clientY); }, showPopup: function (x, y){ var popup = document.getElementById(&quot;popup&quot;); popup.style.left = x + &quot;px&quot;; popup.style.top = y + &quot;px&quot;; popup.className = &quot;reveal&quot;; } };
  • 74. Separe configurações function validate(value) { if (!value) { alert(&quot;Invalid value&quot;); location.href = &quot;/errors/invalid.php&quot;; } };
  • 75. Separe configurações var config = { urls: { invalid: &quot;/errors/invalid.php&quot; }, strs: { invalidmsg: &quot;Invalid value&quot; } }; function validate(value) { if (!value) { alert(config.strs.invalidmsg); location.href = config.urls.invalid; } };
  • 76.
  • 77. Qualquer texto exibido para o usuário
  • 78. Qualquer HTML que precisa ser criado pelo javascript
  • 81. Qualquer coisa que talvez seja modificada no futuro, e utilizada em mais de um lugar
  • 82. Otimizando Loops: var names = ['George','Ringo','Paul','John']; for(var i=0;i<names.length;i++){ doSomeThingWith(names[i]); } var names = ['George','Ringo','Paul','John']; var all = names.length; for(var i=0;i<all;i++){ doSomeThingWith(names[i]); }
  • 83.
  • 84. Isso inclui expressões regulares, mas primeiro e mais importante: DOM manipulation (CAUTION!)
  • 85. Você pode criar nós do DOM no loop, mas evitar sua inserção no documento
  • 87.
  • 88. - Mark 'Tarquin' Wilton-Jones, Opera
  • 89.
  • 90.
  • 93.
  • 94.
  • 95. - Chris Waterson, Mozilla
  • 96.
  • 98. DOM nodes added or removed
  • 101.
  • 104.  
  • 105.
  • 106.
  • 107. Medium: Colocar 'display' do elemento como 'none', aplicar modificações, colocar 'display' volta ao padrão
  • 108. Fuck yeah!: Construir modificações do DOM num 'DocumentFragment' e depois aplicar tudo de uma vez
  • 109.
  • 111. Seu pai é o document que o gerou
  • 112. Quando passado para 'appendChild()', adiciona todos seus filhos ao invés de si próprio
  • 113.  
  • 114.
  • 117.  
  • 118.
  • 119. Definir a classe CSS com todas modificações e então apenas modificar a propriedade 'className'
  • 120. Definir diretamente o 'cssText' no elemento
  • 121.  
  • 122.  
  • 123.
  • 125.
  • 126.  
  • 127.
  • 128. Se um valor é usado mais de uma vez, armazene-o em uma variável local
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143. Limita a qtd. de tempo que um script tem para ser executado
  • 144.
  • 145.
  • 146. Exceção: Opera não tem runaway timer
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 154. Chrome: Unknown, hooks into normal crash control mechanism
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163. Schedules a new JavaScript execution job for some time in the future
  • 164.
  • 165.
  • 166. Use timers to delay some processing for later
  • 167.
  • 168.
  • 169.  
  • 170.
  • 171.
  • 172. No access to DOM, BOM
  • 174.
  • 175.
  • 176. UI cannot be updated while JavaScript is executing
  • 177. Keep JavaScript execution to 50ms – use timers and/or web workers to offload processing
  • 179.
  • 180. Porém, deve ser usado com cautela, pois ao mesmo tempo que pode melhorar o código pode às vezes prejudicar a performance
  • 181. Principal teoria: html / css selectors
  • 184.
  • 185. div.photo, div.title and div.rating são filhos 'imediatos' do div.container
  • 186. Cada div.star é filho de div.rating
  • 187. Quando uma div.star tem a class 'on', é uma estrela selecionada
  • 188.
  • 189.
  • 190.
  • 191.
  • 192. A selector expression is passed to children() to narrow the result down to only the full stars.
  • 193. If children() receives no parameters, all immediate children will be returned.
  • 194. No grandchildren will be returned. Sorry.
  • 196.
  • 197. The following example should be pretty straightforward. The full stars are filtered out from a collection of all five stars.
  • 198.
  • 199.
  • 200.
  • 201. Again, very straightforward. The photo box is added to the selection.
  • 202.
  • 203. The second parameter is the zero-based index of the first element NOT to be included in the returned slice. If omitted, the slice extends to the end of the set.
  • 204. So slice(0, 2) selects the first two stars.
  • 205. .slice
  • 206.
  • 207. As shown in the figure below, the first star’s direct parent is selected. Very handy, hah?
  • 208. It should be noted that only the direct parent will be returned, which is why it’s singular. No grandparent or ancestors will be selected.
  • 209.
  • 210. By passing ‘.container‘ to parents(), div.container, which actually is the grandparent of the first star, is selected.
  • 211.
  • 212.
  • 213. The ‘odd’ siblings are selected as shown. Again, the index is zero-based. Look at the red numbers below the stars.
  • 214.
  • 215. The prevAll() selects all previous siblings of a set of elements.
  • 216. This is super handy if you’re building a star rating widget. The previous siblings of the third star are selected.
  • 217.
  • 218.
  • 219.
  • 220.
  • 221. The output of one function can be the input of another – that is to say, they’re chainable .
  • 222. Multi-select transfer $().ready(function() { $('#add').click(function() { return !$('#select1 option:selected').appendTo('#select2'); }); $('#remove').click(function() { return !$('#select2 option:selected').appendTo('#select1'); }); });
  • 223. Multi-transfer <html> <head> <script src=&quot;jquery-latest.js&quot; type=&quot;text/javascript&quot;></script> <script type=&quot;text/javascript&quot;> $().ready(function() { $('#add').click(function() { return !$('#select1 option:selected').remove().appendTo('#select2'); }); $('#remove').click(function() { return !$('#select2 option:selected').remove().appendTo('#select1'); }); }); </script> <style type=&quot;text/css&quot;> a { display: block; border: 1px solid #aaa; text-decoration: none; background-color: #fafafa; color: #123456; margin: 2px; clear:both; } div { float:left; text-align: center; margin: 10px; } select { width: 100px; height: 80px; } </style> </head> <body> <div> <select multiple id=&quot;select1&quot;> <option value=&quot;1&quot;>Option 1</option> <option value=&quot;2&quot;>Option 2</option> <option value=&quot;3&quot;>Option 3</option> <option value=&quot;4&quot;>Option 4</option> </select> <a href=&quot;#&quot; id=&quot;add&quot;>add &gt;&gt;</a> </div> <div> <select multiple id=&quot;select2&quot;></select> <a href=&quot;#&quot; id=&quot;remove&quot;>&lt;&lt; remove</a> </div> </body> </html>
  • 224. Select all $('form').submit(function() { $('#select2 option').each(function(i) { $(this).attr(&quot;selected&quot;, &quot;selected&quot;); }); });
  • 225.
  • 226. Extremamente útil, se souber utilizá-lo devidamente
  • 232.
  • 233. A última solução poderia ser ainda melhorada, salvando antecipadamente o atributo '.length'
  • 234. .append var arr = [1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf', 1, 2, 3, 4, 5, 'adsf', 'as', 6, 2, 3, 6, 'ffadscdasc', 'cada', '2wd', 3, 7, 3, 2, 'sdf'];
  • 235.
  • 238. Event .toggle and animation .toggle <html> <head> <style> ul { margin:10px; list-style:inside circle; font-weight:bold; } li { cursor:pointer; } </style> <script src=&quot;jquery-latest.js&quot;></script> </head> <body> <ul> <li>Go to the store</li> <li>Pick up dinner</li> <li>Debug crash</li> <li>Take a jog</li> </ul> <script> $(&quot;li&quot;).toggle( function () { $(this).css({&quot;list-style-type&quot;:&quot;disc&quot;, &quot;color&quot;:&quot;blue&quot;}); }, function () { $(this).css({&quot;list-style-type&quot;:&quot;disc&quot;, &quot;color&quot;:&quot;red&quot;}); }, function () { $(this).css({&quot;list-style-type&quot;:&quot;&quot;, &quot;color&quot;:&quot;&quot;}); } ); </script> </body> </html>
  • 239. Chrome permissions chromium-browser --allow-file-access-from-files
  • 240.
  • 241. .load( url [, data] [, complete(responseText, textStatus, XMLHttpRequest)] )
  • 242. .get or .load? $.get('ajax/test.html', function(data) { $('.result').html(data); alert('Load was performed.'); }); $('.result').load('ajax/test.html', function(){ console.log('finished!'); }); $('#b').load('article.html #target');
  • 243. .load $(&quot;#success&quot;).load(&quot;/not-here.php&quot;, function(response, status, xhr) { if (status == &quot;error&quot;) { var msg = &quot;Sorry but there was an error: &quot;; $(&quot;#error&quot;).html(msg + xhr.status + &quot; &quot; + xhr.statusText); } });
  • 244.