Using AJAX to pass variable to PHP and retrieve those using AJAX again

前端 未结 5 1969
别跟我提以往
别跟我提以往 2020-11-30 06:41

I want to pass values to a PHP script so i am using AJAX to pass those, and in the same function I am using another AJAX to retrieve those values.

The problem is th

5条回答
  •  醉话见心
    2020-11-30 07:39

    you have to pass values with the single quotes

    $(document).ready(function() {    
        $("#raaagh").click(function(){    
            $.ajax({
                url: 'ajax.php', //This is the current doc
                type: "POST",
                data: ({name: '145'}), //variables should be pass like this
                success: function(data){
                    console.log(data);
                               }
            });  
            $.ajax({
        url:'ajax.php',
        data:"",
        dataType:'json',
        success:function(data1){
                var y1=data1;
                console.log(data1);
                }
            });
    
        });
    });
    

    try it it may work.......

提交回复
热议问题