php - jquery, how to get var from $.ajax POST? -
edit3: I am using this script inside a Facebook app, and not to make sure that
I am passing a var in a php file using a post:
& lt; Div id = "talentnum" class = "cont_talentnum" & gt; & Lt ;? Php echo $ number; ? & Gt; & Lt; / Div & gt; & Lt; One square = "my_click" href = "#" & gt; & Lt; / A & gt; JS here
var strtalentnum; $ ('My_click'). Search Live ('click', function () {strtalentnum = $ (this) .closest ("li"). (". Cont_talentnum"). Text (); $ ('# mine'). Trigger ('click') ;}); Click $ ("my mine") (function () {if (strtalentnum) {$ .ajax ({type: "POST", url: "fb_test.php", data: strtalentnum, success: function () {var talentnum = Stratlanum; // This is 6203222 Warning (Stratentum);}}};}}); and the php file is:
& lt ;? Php function fb_test () {echo 'xxx'; echo $ _GET ['strtalentnum'];}? & Gt; Then I call the function on the same HTML page:
& lt ;? php function fb_test ();? & Gt; If I run it, then I get only xxx I also get success warning my case I get '6203222' , so I know that is posted See if I can see in the Chrome Network header:
Request method: Post Status Code: 200 Fine Form Data 6203222: Why can not I get it $ _ GET ['? Any thoughts?
Thanks
Edit: $ _ POST ['strtalentnum']; job is used edit2 added html
Name is required for:
var strtalentnum = $ ('# strtalentnum'). Val (); $ ("# My") click (function () {if (strtalentnum) {$ .ajax ({type: "POST", url: "fb_test.php", data: "strtalentnum =" + strtalentnum, data type: 'Html', success: function (var) = parallel string =; it is 6203222 warning (stratlan);}}}}}}); form: < & Lt; input method = "post"> & lt; input id = "My" type = "submit" name = "submit" />
test it now:
& lt ;? php function fb_test () {echo 'xxx'; echo $ _PO ST ['strtalentnum'];}? & Gt;
Comments
Post a Comment