How can I pass a variable from JSON to PHP? -
I am using JSON, which is to create some data on WordPress, which I store in PHP session variable There is a current setup here that I'm messing around but there is no luck:
jQuery (document) .ready (function ($) {$ .ajax ( {Url: 'url', type: 'post', datatype: 'jason', data: {foo: 145}, success: function (data) {console.log (data); alert (data);}}); }); and PHP:
session_start (); $ _SESSION ['bar'] = $ _POST ['foo']; I can see the data in the console, but when I echo my shell, nothing will be displayed. Using wardump gives an empty array.
(I know that there are so many other questions like this, but believe me, I have tried all of them Nada.)
Answer: You can not use JavaScript to store server side variables. Do you want to save $ _SESSION var in PHP script that this AJAX call you have put url ?? In WordPress you can use JQuery to call a special hook which can hold that function. Php which handles all AJAX.
There is information everywhere about this, see the solution to this answer:
Comments
Post a Comment