javascript - Get a variable value in the url using ajax -
I'm new to AJAX in this code how do I get variable 'zero' value in a.php?
This code is:
HTML:
& lt; Div class = "div1" & gt; & Lt; / Div & gt; & Lt; Button & gt; Click & lt; / Button & gt; AJAX:
& lt; Script type = "text / javascript" & gt; var zero = $ ('# query'). valueOf () ;; $ (Document) .ready (function (e) {$ ('button'). Click (function () {$ .ajax ({url: "a.php", type: "post", data: zero, success : Function (result) {$ ('. Div1'). Html (result);}});});}); & Lt; / Script & gt; a.php:
& lt ;? php $ zero = $ _POST ['data']; Zero to zero; ? & Gt;
When sending data, send it as key = value pair. In your case, AJAX changes such data in the request.
Data: "zero =" + zero
do this while entering PHP
$ zero = $ _POST ['zero'];
Comments
Post a Comment