Example Analysis of php+ajax+json
This article mainly shows you the "sample analysis of php+ajax+json", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "sample Analysis of php+ajax+json".
Php+ajax+json instance code
Html page:
(function () {$("# send") .click (function () {var cont = $("input"). Serialize (); $.ajax ({url:'ab.php', type:'post', dataType:'json', data:cont, success:function (data) {var str = data.username + data.age + data.job; $("# result") .html (str);}})) });}); look at the display result later
Name:
Age:
Work:
Submit
Php page:
Use post mode
(function () {$("# send") .click (function () {var cont = {username:$ ("input") [0] .value, age:$ ("input") [1] .value, job:$ ("input") [2] .value}; var url = 'ab.php'; $.post (url,cont,function (data) {var res = eval ("(" + data + ")") / / convert to Object object var str = res.username + res.age + res.job; $("# result") .html (str);}); above is all the content of the article "sample Analysis of php+ajax+json". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!