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:


$(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,

$(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?

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.

Thanks. I learned something today! :slight_smile:

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:


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.