Jump to content

Multiple variables in jQuery from PHP


waldette

Recommended Posts

Hello all, i have a problem processing multiple varibles between php and jquery.

 

js file:

$.ajax({
  type: "POST",
  url: "process.php",
  data: postData,
  success: function(result) {

 

i need to send differents variables from php to this js file.

 

Example:

result.one

result.two

...

 

Is it possible get multiple variables from php to js?

 

Then i need do this, for example:

success: function(result) {
if(result.ONE == yes){
	   ....
}else if (result.TWO == anything){
		   ....
  }

 

help pls!

Link to comment
Share on other sites

the question is where you use this php file? it's a module? controller? external script?

everytyhing depends on it.

 

what to do?

you have to create template file with simple echos.

just append variables to the smarty assign array, then in the tpl file use:

 

<script>

myvariable={$first_variable};

another={$second_variable};

</script>

 

and you will be able to use these variables from script that you creating.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...