I have a variable that we call test_string, I am also specifying the string "hello".
var test_string = "Hello"; And I want to post it on a php page, which I've tried:
$ Post ('php_page.php', test_string); I use php_page.php:
$ new_var = $ _POST ['test_string']; Echo $ new_var; Do not get any results What am I missing in $ .post ()?
try it ---
$ Post ('php_page.php', {test_string: test_string}); and tell me
edit my work code --- test.php & Lt ;; DOCTYPE HTML PUBLIC "- // W3C // DTD XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "http://code.jquery.com/jquery-latest.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function handle () {var test_string = "hello"; $ .post ('myphp.php', {'test_string': test_string}, work (results) {$ ("span"). Html (results);}); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "button" onclick = "handle ();" Value = "click" /> & Lt; Period & gt; & Lt; / Span & gt; & Lt; / Body & gt; & Lt; / Html & gt; myphp.php
& lt; Php $ new_var = $ _POST ['test_string']; Echo $ new_var;
Comments
Post a Comment