Thank you for looking at the question.

I'm trying to get the value of an HTML textbox with jquery and pass the value to PHP with "ajax", but it doesn't work.
I thought about it all day long, but it didn't work.

The following source code is a partial excerpt.
All the source code below is written in a single file, and there is also the ajax URL path.
I have no idea, so please give me some advice.
Thanks for your cooperation.

**HTML file**
<input type="text">
function test01(){
    data = $("#test01").val();
        data: data,
        success: function(response){
        error: function(response){
$data = $_POST;
  • Answer # 1

    dataIs created incorrectly. If you use the question method, nothing will be sent.
    In the first place$dataWhendataIs another variable.

    The quickest way is to get the form object with jquery,serializeIs to do.

    For example, the id of form istestformIf

      function test01(){
                ,data: $("#testform").serialize()

    For example, all the contents of form will be sent.

  • Answer # 2

    You're putting the url beginning with http in the url, right?
    Is it a CORS issue? Check the error status in the development tool