SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post pass serialize data

    Hi, I just want to ask some help regarding in window.open,is it possible to pass data serialize form?

    I tried this but it would not work

    Code:
      dataform = $('#myform').serialize();
      window.open('anotherpage.php?data='+dataform);
    Thank you in advance.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jemz View Post
    I tried this but it would not work

    Code:
      dataform = $('#myform').serialize();
      window.open('anotherpage.php?data='+dataform);
    Thank you in advance.
    Have you seen what the dataform string contains? It will contain key/value pairs so they won't be accessible via the data key, but instead through the names of the form fields instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi paul,
    Thank you for the reply,yes i tried to use the names of the fields and it's working but can i ask
    is it possible to use the window.open and encrypt the data I mean the parameters?

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You can use Base64 encoding but of course anyone can decode the string, if you want to protect the data you would need to post the data instead of using a query string.

  5. #5
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,388
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by jemz View Post
    is it possible to use the window.open and encrypt the data I mean the parameters?
    What kind of data are you trying to pass between pages in this way? You may be better off putting the data in a session on the server, or in a DB, depending on what kind of data you're working with.

  6. #6
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris.upjohn View Post
    You can use Base64 encoding but of course anyone can decode the string, if you want to protect the data you would need to post the data instead of using a query string.

    Is is it possible to post the data using window.open?

  7. #7
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    What kind of data are you trying to pass between pages in this way? You may be better off putting the data in a session on the server, or in a DB, depending on what kind of data you're working with.

    Hi fretburner, I have this kind of data since i could not pass data using the serialize form,I just do it like this window.open('tootherpage.php?bankname'=+banckname+'&address='+address etc..);

    you mean to do this in session like this

    $_session['bankname'] = "mybankname";
    $_session['address'] = "banckaddress";
    etc...

    Thank you in advance.

  8. #8
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,388
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Well, as you're talking about data from a form, why not just submit the form in the normal way? And if you're dealing with sensitive data such as bank details you should only do this over HTTPS.

  9. #9
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi fretburner,
    what do you mean by this,sorry i could not get
    should only do this over HTTPS.

  10. #10
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,388
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    I mean that if you're going to be submitting sensitive data, it's not safe enough just to submit by post. You need to submit the form over a secure connection (i.e your form action will be something like: https://www.example.com/account/mybankdetails.php).

  11. #11
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    I mean that if you're going to be submitting sensitive data, it's not safe enough just to submit by post. You need to submit the form over a secure connection (i.e your form action will be something like: https://www.example.com/account/mybankdetails.php).

    Hi fretburner, I don't know how to do https do i have to configure in my server in order to get the https ?

  12. #12
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,388
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    You need to buy a SSL certificate and ask your hosting company to install it for you. Then usually your files are available via both http and https.

  13. #13
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you fretburner for this information

  14. #14
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Its not hard to post data to a new window, all you need to do is set the target on the form itself to the name of the popup window and when you hit submit the data will get posted to it instead of reloading the current page. See the following link for an example.

    http://taswar.zeytinsoft.com/2010/07...dow-or-pop-up/


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
  •