Inserting text into a textarea using .load() in jQuery
- by bateman_ap
Hi, having a bit of a nightmare, I am trying to use jQuery to insert some text taken from a .load() call into a form field (textfield) after a user logs in (basically prefilling some known details)
The code I am using is:
$.ajax({
type: "POST",
url: "/ajax/login.php",
data: dataString,
success: function(html) {
if (html == 1) {
$("#loginPanel").load("/ajax/login-panel.php");
$("#bookName").load("/ajax/getSessionDetails.php #userUsername");
$("#bookEmail").load("/ajax/getSessionDetails.php #userEmail");
$("#bookingLogin").hide("fast");
} else {
$("#loginError").html("Sorry, login failed, please try again");
}
}
});
If I hardcode such as $("#bookName").html("Test Content"); it works OK so it must be a problem with the .load call.
I looked around and found some guy suggest something like the following code but I couldn't get it to work:
$.get(htmlBannerUrl, function(data){
$('textarea').val(data);
});