Insert text into textbox using .load () in jQuery

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);
});
+3
source share
3 answers

You can also use text ();

$('#loginError').text();
+2
source

, ajax:

$("#loginPanel").load("/ajax/login-panel.php");     
$("#bookName").load("/ajax/getSessionDetails.php #userUsername");
$("#bookEmail").load("/ajax/getSessionDetails.php #userEmail");

HTTP 1.1 2 . $.ajax, , , . .:

AJAX (XmlHttpRequest) ?

0

, , , , , , , .

php- .load. , , , , , .

, , Stackoverflow?

0

Source: https://habr.com/ru/post/1745485/


All Articles