Web Hosting Forum - Net Hosting Talk

We are a community of individuals and businesses passionate about web hosting. Let's build, learn, and grow together.

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

barnes

Novice
Member
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!!
 
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
  • 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

    Back
    Top