Ajax post to php on same page not working

后端 未结 2 372

I am trying to pass a var from jQuery to PHP.

After researching I found the most common suggestion was to do this with Post with Ajax and store the pos

相关标签:
2条回答
  • 2020-12-22 01:41

    Try

    <script>
       $.ajax({
          type: "POST",
          url: "http://currentpage.com",
          data: {variablename:'value'},
          dataType: "text", //Available types xml, json, script, html, jsonp, text
          success:function(response){
           //Returned from server
           alert(response);
          }
        });
     </script>
    
    0 讨论(0)
  • 2020-12-22 02:03
    <script>
       $.ajax({
          type: "POST",
          url: "index.php",
          data: {var:'value'},
          dataType: 'text',
          success:function(data){
           // Test what is returned from the server
             alert(data);
          }
        });
     </script>
    
    0 讨论(0)
提交回复
热议问题