如何让AJAX在第二页上发布?

时间:2017-01-27 17:34:12

标签: javascript php jquery ajax

这就是发生的事情:我发送数据但是我已将其编码以在第二页上回显。但是,它只是在第一页上回应。我该怎么做才能在第二页而不是第一页回显?

第二页上的代码执行但在第一页上执行。我希望它在第二页。



<!doctype html> FIRST PAGE
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<div class="text-center"><a href="#" class="btn btn-grn" id="scaleButton">Button</a></div>
<input class="form-control" name="cartID" id="cartID" type="hidden" value="<?php echo $order['clientid'] ;?>">
	<p id="edit_box"></p>
<script>
	
$("#scaleButton").click(function()	{ 
var cartID = "hello"
var second = "second";
	
///////// AJAX //////// AJAX //////////
    $.ajax({
        type: 'POST',
        url:  'user/testing1234.php',
        data: {first:cartID,second:second},
        success: function( response ){
            alert('ajax');
            $('#edit_box').html(response);//this is where you populate your response
        }//close succss params
    });//close ajax
///////// AJAX //////// AJAX //////////
})
</script>


</body>
</html>


SECOND PAGE
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>

<body>

<?php
$first = $_POST['first'];
$second = $_POST['second'];
$third = $_POST['third'];


echo $second;
echo $second;
echo $second;
?>


</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这就是我需要的信念:

read_csv(['data1', 'csv'] + '.csv')

对于您的HTML页面:

$( document ).ready(function() {

$("button").click(function() {
var dataPoint = "chunk of data";
    ///////// AJAX //////// AJAX //////////
        $.ajax({
            type: 'POST',
            url:  'some_page_name.php',
            data: {dataPoint:dataPoint},
            success: function( response ){
                $('#success').html("Sent!!");
            }
        });
    ///////// AJAX //////// AJAX /////////

  });

根据需要进行修改。