jQuery ajax return value
Posted
by
Jordan Pagaduan
on Stack Overflow
See other posts from Stack Overflow
or by Jordan Pagaduan
Published on 2011-02-13T07:19:33Z
Indexed on
2011/02/13
7:25 UTC
Read the original article
Hit count: 193
How can I return the value "pinNumber" from jquery ajax so I can append it outside of the ajax. Here is my code
var x = pinLast + 1; for(i=x;i<=pinMany;i++) { var i = x++; var cardNumber = i.toPrecision(8).split('.').reverse().join(''); var pinNumber = ''; jQuery.ajax({ type: "POST", url: "data.php", data: "request_type=generator", async: false, success: function(msg){ var pinNumber = msg; return pinNumber; //pin number should return } }); jQuery('.pin_generated_table').append(cardNumber+' = '+pinNumber+'
'); // the variable pinNumber should be able to go here }
Please ask me if you don't understand.. ^^ thanks
© Stack Overflow or respective owner