0

How can I insert a value to variable with:

$("#TEST").load("GET.php #Message_1");

An example of that:

var MSG = $("#TEST").load("GET.php #Message_1");

alert(MSG);

2 Answers 2

1

You need to get the value in the callback function:

$("#TEST").load("GET.php #Message_1", function() {
    var msg = $(this).text();
    alert(msg);
});
Sign up to request clarification or add additional context in comments.

3 Comments

thanks, is work! but how i can use the variable 'msg' out of function ?
Assign a global variable instead of a local variable. But remember, it won't be available until after the callback executes.
You can give me example?
0

This should work:

$("#TEST").load("GET.php #Message_1");

var msg = $("#TEST").val();
alert(msg);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.