SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast aouton's Avatar
    Join Date
    May 2003
    Location
    mexico
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery ftp login

    Hi all.

    I ask for some help/advise.

    I have a jquery form dialog to collect usr/pwd in order to do a ftp login.

    I have the form working and the dialog is showing me the correct values for the fields but the dialog I have is not working (I am newbie with jquery) nothing happens. My guess is the .ajax but I cannot be sure.

    Here is the code I have:

    Code:
    $(function(){
        $('#ftp').dialog({
            autoOpen: false,
            show: 'highlight',
            hide: 'scale',
            modal: true,
            buttons: {
                'send': function() {
                    var name = $('#usr').val(), password = $('#pwd').val();
                    var myftp = $(this);
    
                    if (name != '' && password != '') { // alert('name=' + name + '&pass=' + password);
                        $.ajax({
                          type: 'POST',
                          url: 'ftp.php',
                          data: 'name='+name+'&pass='+password,
                          success: function(msg){
                            alert(msg);
                            $(myftp).dialog('close');
                          }
                        });
                    }
                },
                'close': function() { $(this).dialog('close'); }
            },
            resizable: false,
            width: '500px'
        });
    ftp.php is a simple header ('location: ... ) to call the ftp with the proper parameters.

    #ftp is the form id containing usr/pwd.

    I don't know if jquery has the equivalent functionality. I am more familiar with php

    I really appreciate your help with this.

    Regards,

  2. #2
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $(myftp).dialog('close'); should be myftp.dialog('close');

    You don't reference variables that are already objects with dollar sign and parentheses.

    Other than that, your call looks correct. What are you expecting to happen and what are you getting returned?
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  3. #3
    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)
    My reply has nothing to do with the question but more about the major security risk you pose for not only your users but your server as i have said in the past the only time you should ever send passwords via AJAX is when using SSL as a hacker can easily just walk between the connection and start taking information.

  4. #4
    SitePoint Enthusiast aouton's Avatar
    Join Date
    May 2003
    Location
    mexico
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by downtroden View Post
    $(myftp).dialog('close'); should be myftp.dialog('close');

    You don't reference variables that are already objects with dollar sign and parentheses.

    Other than that, your call looks correct. What are you expecting to happen and what are you getting returned?
    Thanks. I learned something today!

    Quote Originally Posted by SgtLegend View Post
    My reply has nothing to do with the question but more about the major security risk you pose for not only your users but your server as i have said in the past the only time you should ever send passwords via AJAX is when using SSL as a hacker can easily just walk between the connection and start taking information.
    I understand your point.

    Here is the final result. This is solved. What I needed was simple to call another page and forgot about this one, so I change the .ajax into this:

    Code:
    if (name != '' && password != '') {
    window.parent.location="http://domain.com/ftp.php?" + 'name='+name+'&password='+password;
    }
    Of course, the security issue remains.

    Any suggestion to use POST (equivalent) instead?

    Thanks again.


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
  •