Thursday 15 April 2010

Pass a variable from a javascript function to another php file -



Pass a variable from a javascript function to another php file -

this question has reply here:

what difference between client-side , server-side programming? 6 answers

i new javascript , php , need help. have javascript function within php file. in javascript function have variable want pass php file. can help me how this.

thanks

there several ways can this. simplest way is:

var mydata = 'whatever'; window.location.href = 'otherscript.php?mydata=' + mydata;

then script 'otherscript.php' can access variable $_get['mydata'].

this method requires page refresh. can without refreshing page using ajax, little bit trickier.

javascript php variables

No comments:

Post a Comment