having a bit of a nightmare, I'm trying to use jQuery to insert some text taken from a call to .load () into a form field (text field) after a user logs in (mostly with pre-populating some known details). These are #bookName and #bookEmail. I have problems with
The code I use 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 am hard-coded, for example $("#bookName").html("Test Content");, it works fine, so this is a problem with calling .load.
I looked around and found that some guy was offering something like the following code, but I could not get it to work:
$.get(htmlBannerUrl, function(data){
$('textarea').val(data);
});
source
share