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

Welcome to our community

Be apart of something great, join today!

barnes

Newbie
Messages
14
Reaction score
1
Points
3
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
Points
8
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 :)
 
  • Advertisement
  • Daniel204

    Newbie
    Messages
    7
    Reaction score
    0
    Points
    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