SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    PEACE WILL WIN abalfazl's Avatar
    Join Date
    Feb 2005
    Location
    Beyond the seas there is a town
    Posts
    711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    send a variable from Jscript to PHP

    Say I have a box , I want to send a variable from Jscript to PHP

    Is it possible by using serialize() ?
    I shall build a boat,I shall cast it in the water,
    I shall sail away from this strange earth,
    Where no one awaken the heroes in the wood of love

  2. #2
    SitePoint Addict Zarin Denatrose's Avatar
    Join Date
    Jan 2009
    Location
    Surrey BC, Canada
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When going from Javascript (A client side language) to PHP (A server side language)
    a server call will have to be made. This is typically done using AJAX, which is made incredibly simple using jQuery.

    Here's a related sitepoint article: http://articles.sitepoint.com/article/ajax-jquery

  3. #3
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by abalfazl View Post
    Say I have a box...
    What is 'a box'?
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  4. #4
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes only way to go from javascript to php is through AJAX unless you are accessing SERIALIZED objects from the database.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing that was not mentioned here, is that by default there is not serialization function in JavaScript.

    Although it can be done using JSON.stringify() or some JS framework (if it has such functionality). Ofcourse you will serialize your JavaScript objects to JSON string, which can be decoded back in PHP using json_decode function.

    Like guys before me said, string transfer has to be done with AJAX.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is serialized?? i thought the only way to do it was ajax...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •