Json, $jquery ajax Where to find the documentation for down's syndrome?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
15 views
Read a lot of guides and cheat sheets, and I can't figure out how it works.
Chew the example js and php code please! or help to find very clear documentation
by | 15 views

1 Answer

0 like 0 dislike
It is actually not too difficult.
What happens when you enter a URL into the address bar in the browser? If it is very simplistic:
  1. The browser sends a request to this URL
  2. The server works off PHP and the browser returns some information (in most cases HTML)
  3. The browser displays this information on screen.


In the case of AJAX, the overall essence remains the same:
  1. JavaScript (instead of the address bar) asks the browser to make a request for a certain URL
  2. The browser sends a request to this URL
  3. The server works off PHP and the browser returns some information
  4. Instead of displaying information on the screen, the browser passes it to JavaScript
  5. All data are under the control of the script. and we can do anything.


In its simplest form, an AJAX request using JQuery looks like this:
$.ajax({ url: 'some url' //URL where request is made }).done(function(dataFromPHP){ //We get here if the request completed successfully //All PHP was put into the browser for a classic appeal //through the browser (text, HTML, anything), //will be read by JavaScript and placed into the variable dataFromPHP. //Next, we can freely operate with these data. //For example, to show using alert alert(dataFromPhp); }).fail(function(){ //Here we find ourselves, if for some reason the request was not successfully alert('failed to query') });


I posted a couple of simple examples of using AJAX on github: https://github.com/Merzley/ajax-examples. For running nothing but PHP is not required. If something is not clear please contact
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users