I have a javascript functions which returns a hash. I need to pass this hash to php to do stuff with it. Whats the best way to do that?
3
-
Do you mean, you have a JavaScript function which returns a hash, and then you would need to pass that hash to PHP?Anthony Forloney– Anthony Forloney2010-10-13 01:26:21 +00:00Commented Oct 13, 2010 at 1:26
-
2question and description are opposite :)zod– zod2010-10-13 01:27:17 +00:00Commented Oct 13, 2010 at 1:27
-
possible duplicate of How to pass a variable / data from javascript to php and vice versa?outis– outis2012-03-09 01:07:42 +00:00Commented Mar 9, 2012 at 1:07
Add a comment
|
5 Answers
1 Comment
Kranu
+1: Yup, AJAX ftw. Although it's not that hard to do it with just simple Javascript commands, I recommend that you use jQuery if you're comfortable with it because it keeps the familiar jQuery syntax and compatibility with you.
You should give more info about what exactly you are trying to do. Like this all we can do is guess and you'll get no good answers. But the usual suspects in this case are:
AJAX (or JSON)
Cookies
Hidden form fields, where you set the value via JS
Give more info and we can be more specific.
Comments
look into jquery, this will make your this easier!
$.get('myphp.php?senddata='+javascriptdata,function(receivedata){
alert('this is what was received' + receivedata);
});
or you could set a hidden input's value in a form and submit.
3 Comments
b_i_d
Come on... jQuery just for one single AJAX call? Are you trying to give the term "overdone" a whole new meaning? Nothing against jQuery, but it's not the holy grail for everything.
b_i_d
OK, if you already use jQuery in that project it's the obvious choice. As long as you don't include a whole library just to use one single function. ;)