javascript - $_POST empty after ajax post called -
Then using this AJAX post, I have to use some JS variables in the WordPress loop, so I have a custom loop, ajax post Depends on the basis of variables in
Below is the AJAX call.
$ ('collection-more'). Click (function () {$ .ajax ({type: 'post', url: 'http://tmet.dev/wp-content/themes/muban-trust/single-collection.php', data: {" Test ":" hello "}, success: function (data) {console.log (data);}})}} Currently I am sending hard-coded data. / P>
In my single-collection .php page:
& lt ;? php print_r ($ _ POST); if (isset ($ POST ['filter [artist]'] ]) $ $ Filter_obj = $ _POST ['filter [artist]']; $ filter_array = json_decode ($ filters_obj, TRUE); $ i = 0; $ i & lt; size ($ filter_array); $ i + +) {Resonant '& lt; p & gt; h'. $ Obj- & gt; name. '& Lt; / p & Gt; ';}}? & Gt; I'm just using print_r to debug the problem, currently returns this return:
Array ()
The problem is that I can not
thanks in advance!
EDIT: Screenshot of the screenshot Firebug
And then when AJAX calls
$ Ajax ({url: "somephp.php", type: 'post', data: payload, data type: 'jason', crossdaman: true}) javascript from phpPost : The correct way to get the post parameters: $ fields = $ _POST ['fields']; $ UsernameGiven = $ fields ['smth1']; $ PasswordGiven = $ field ['smth2']; and when smthn back in javascript
$ result = array ("something" = & gt; "something", "something 2" => gt; ; $ Something2); Echo json_encode ($ result);
Comments
Post a Comment