Skip to main content

Posts

Showing posts from January, 2018

How to Use jQuery’s $.ajax() Function Related Topics:

(1)write code for form.html file: <!doctype html> <html lang="en"> <head> <title>passing form input value to php - BY OM SIR</title>   <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>   <script type="text/javascript"> $(document).ready(function (event) { // triggered when the form submitted $("#myform").on('submit',(function(event) { event.preventDefault(); $("#response").empty(); $.ajax({ // URL to move the uploaded image file to server url: "pass.php", // Request type type: "POST", // To send the full form data data: new FormData(this), contentType: false,    processData:false,   // UI response after the file upload success: function(data) { $("#response").html(data); } }); })); // Triggered when the image changed (browse) // Function to show the image as a preview }); </script> </head>

Jquery with Ajax

What About jQuery and AJAX? jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page! Without jQuery, AJAX coding can be a bit tricky! Writing regular AJAX code can be a bit tricky, because different browsers have different syntax for AJAX implementation. This means that you will have to write extra code to test for different browsers. However, the jQuery team has taken care of this for us, so that we can write AJAX functionality with only one single line of code.

Ajax with php

FIRST CREATE  TABLE    details : create table  details (id  int, name   varchar(200), city    varchar(200)); Ajax example code  for   inserting record from  form   to MYSQL  Database : (1)first write code for  insert.html   file: <html> <head> <script> function ajax_post() {     // Create our XMLHttpRequest object     var hr = new XMLHttpRequest();           // Create some variables we need to send to our PHP file           var url = "insert.php";           var id = document.getElementById("id").value;           var nm = document.getElementById("name").value;             var cy = document.getElementById("city").value;                 var vars = "id="+id+"&name="+nm+"&city="+cy;           hr.open("POST", url, true);     // Set content type header information for sending url encoded variables in the request     hr.setRe

Ajax Event

(1)Ajax  Onclick Event Example: <!DOCTYPE html> <html> <body> <div id="demo"> <h1>The XMLHttpRequest Object</h1> <button type="button" onclick="loadDoc()">Change Content</button> </div> <script> function loadDoc() {   var xhttp = new XMLHttpRequest();   xhttp.onreadystatechange = function() {     if (this.readyState == 4 && this.status == 200) {       document.getElementById("demo").innerHTML =       this.responseText;     }   };   xhttp.open("GET", "ajax_info.txt", true);   xhttp.send(); } </script> </body> </html> (2) Ajax  onmouseover  Event: <!DOCTYPE html> <html> <body> <div id="demo"> <h1>The XMLHttpRequest Object</h1> <button type="button" onmouseover="loadDoc()">Change Content</button> </div> <script> func

Ajax introduction

AJAX  Introduction: AJAX is a developer's dream, because you can: Update a web page without reloading the page Request data from a server - after the page has loaded Receive data from a server - after the page has loaded Send data to a server - in the background What is AJAX? AJAX =  A synchronous  J avaScript  A nd  X ML. AJAX is not a programming language. AJAX just uses a combination of: A browser built-in XMLHttpRequest object (to request data from a web server) JavaScript and HTML DOM (to display or use the data) Note : AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. How AJAX Works: 1. An event occurs in a web page (the page is loaded, a button is clicked) 2. An XMLHttpRequest object is created by JavaScript 3. The XMLHttpRequest object sends a request to a web server 4. The server pr