Welcome to Web Hosting Forum - Net Hosting Talk

Register now and be part of our community! When you register with the Net Hosting Talk you can join in with topics, start new topics, and generally be a part of the first level of our community. It's also quick and totally free, so what are you waiting for?

How do I send a variable from a PHP to AJAX to a form or view?

barnes

Newbie
Messages
11
Reaction score
0
Hello, 

I am trying to get some variables from a php using ajax but I do not know how they are done. 

I have SESSION type variables in PHP, and I want to send them by ajax to a form that is in EXTJS. 

the variable is of this type: $ default_name = $ _SESSION ['default_name']; 

Someone could give me an example of how to send a variable from PHP by AJAX to another?, Because I see pure examples passing data from a form by ajax to php but not backwards. 

Any ideas? 

Thank you very much!!
 

edwin

Moderator
Messages
40
Reaction score
3
If you pass the php variables to an input type hidden:
You don't have permission to view the spoiler content. Log in or register now.
And then you retrieve that value with jquery or javascript or the other would be that those session variables can be obtained from a PHP file (that only delivers those variables), for example, getVariables.php and query that file through ajax and once rescued send them to the file you need :)
 

Daniel204

Newbie
Messages
7
Reaction score
0
With jQuery, assuming is a POST:
You don't have permission to view the spoiler content. Log in or register now.
I used a promise-style callback (.then) instead of using the third arg of the $.post function because it's more clear to read.

Anyway, the $.serialize function creates a URL encoded string, and it's perfect for these cases.

HTH!

Regards,
TechTIQ Solutions
 

Advertisement

Top