views:

49

answers:

2

I am using the code that I will post below. I generates the password and works fine. Only problem is that it shows me the regenerated password in the alert box. I want to echo it on the screen. how can I do that. Thanks Using jQuery fancybox and php

$.ajax({
    type: 'POST',
    url: '/processPassword.php',
    data: 'newPassword=' + password,
    success: function(success) {
        if(success == 1) {
            alert('The password has been reset. to: ' + password);
            location.href = 'mainpage.php';
        } else {
            alert('The password was not reset.');
        }
    }
});
});

function newPassword() {
        var password = "";
        some logic...
        return password;
}
+2  A: 

Try this. Replace the "alert" call with the jQuery line below to set the HTML of a div...

HTML

<div id="newPass"></div>

jQuery

//this assumes that "password" has already been setup.
$("#newPass").html(password); 

I also would strongly advise you to consider having your PHP page generate the password and to use jQuery or something similar to request a PW to be built with server side code. Making the PW with client side code seems to be a huge security hole, almost like giving the blue prints of the prison to the prisoners...

RSolberg
A: 

This is something you could try

$.post {
   "processPassword.php",
   { newPassword: 'password' },
   function(data) {
       alert('Your new password is+'+data) ;
});

In this the data is the value echoed by the page processPassword.php not return so you must echo your new password in the end of page or somewhere.

Starx