JavaScript and Ajax
JavaScript is client side scripting language. When you open a web page your web browser first downloads all the necessary files from the server to display that page correctly. Those necessary files are HTML, CSS, Images, Videos, etc and the JavaScript files too. After completing download the browser displays that page on its window and any script linked with it will run from the downloaded script file.
In Ajax technology, user inputs and other data are sent to the web server through JavaScript. JavaScript creates XML_HTTP_REQUEST_OBJECT to connect with the server, submit data to it, and to request a response from the server. When response comes, a JavaScript event fires and the function associated with that event is then executed. So in Ajax technology JavaScript is only used to transfer data between client side and the server side while the main program, i.e. data processing is executed at the server end, in PHP or any other server side language.
As JavaScript runs from the client computer its execution time is very short, almost instantaneous. Viewers can run JavaScript without being connected with the server as well. But in Ajax, viewers must be connected to the server. Here execution time is much longer which depends on their internet connection speed, server hardware and number of bytes to be transferred between client side and server side.
In terms of server security JavaScript is absolutely safe since it doesn't transfer any user input from client side to the server. But in Ajax you have to take special care to prevent any malicious data from the bad users.
In JavaScript you can't hide your source code. Users can easily read your source code from source view which is running on their computer. But in Ajax data processing takes place at the server end and so user can't see the program source code.
In Ajax you can support your program with your server database.
For a long program, if you use JavaScript to implement it, the size of your web page will be larger. So it will take longer time to download which is a bad SEO feature. But in Ajax you can run long program, processing several thousands of data from a database, still your page size keeps small.
Since all browsers do not strictly follow any particular standard so it is not very easy to write a browser independent JavaScript program.
JavaScript are only used in some specific applications where data security is not an important consideration while the scope of Ajax technology application is unlimited.
0 comments:
Post a Comment