0

Possible Duplicate:
How to pass JavaScript variables to PHP?

how would I go about moving a javascript variable over to a php script without a form submission?

is it even possible?

ajax is an acceptable option but how

lets say I want to run thisnewoption.php in process sending it javascript variable imgfilename which contains a string

Community
  • 1
  • 1
James Stafford
  • 1,034
  • 1
  • 15
  • 41

2 Answers2

2

Once your php page has loaded, there's no going back. The best way to go about passing variables ( data ) back to the server is with ajax, so it might be time to brush up on ajax http://api.jquery.com/jQuery.ajax/

Update: Tell you what, here is what a really basic ajax call looks like, notice that is send data to the server here with POST:

 $.ajax ( {type : 'POST' ,
    url : 'email.php' ,
    data : { variable: variable, anotherVariable: anotherVariable } ,
        success : function ( data ) { $('#some-div').html ( data ) ; }
    } ) ;
Scott Hillson
  • 900
  • 1
  • 12
  • 30
1

You cannot literally pass a javascipt variable as a PHP one as PHP is evaluated on server side where as javascript on client. You can use ajax call to pass it however.

Amareswar
  • 2,048
  • 1
  • 20
  • 36