1

i have problem at jquery post, php get. but i don't get any value. i'm everytime get error. so what i do wrong? there are the codes

it's jquery post:

$.post("a.php", { imagetext: $("textarea").val() } );

it's php get:

echo $_GET["imagetext"];

p.s:i'm beginner at php.

4 Answers 4

3

Because you are sending a POST request, you need to use $_POST["imagetext"]; in your PHP. Alternatively, you could change it to a GET request with jQuery $.get.

Sign up to request clarification or add additional context in comments.

Comments

2

You need to use $_POST["imagetext"] in PHP because you are posting with jQuery. What you are doing is acting like the request was made with GET, but $.post(...) will make a POST request.

Comments

1

The reason echo $_GET["iamgetext"]; doesnt print out anything is because it is not set. At least not by your ajax call.

You have 2 options.

  1. Use echo $_POST["imagetext"];
  2. use $.get() for your ajax call.

Comments

0
$.post("a.php", { imagetext: $("textarea").val() } );
echo $_POST["imagetext"];

You are using the wrong global var, should be like above.

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.