Copy
<script>
$.ajax({
type: 'post',
dataType: 'json',
url: "url",
data:{
"key":"<?php echo $key ?>",
"action":"add",
"service":"<?php echo $service ?>",
"link":"<?php echo $link ?>",
"quantity":"<?php echo $quantity ?>",
},
success: function(data){
console.log(data)
},
error : function(data) {
alert('요청 실패 다시 시도해 주세요');
}
});
</script>
이렇게 요청하면 응답값이
{
"order": 23501
}
이렇게 오는데 여기서 oder 의 응답값을 php 함수로 선언하고 싶습니다
예를들어 $orderid = "order": 23501 이런식으로요 가능 할까요?
답변 1개 / 댓글 6개
채택된 답변
+20 포인트
실행의 순서가 php가 먼저 실행이되고 그 다음이 프론트가 실행이 되는거라
가능하지 않습니다.
오히려 어떤 의도로 뭘하실지 알려주시면 도움을 드릴수 있을것 같습니다.^^;
답변에 대한 댓글 6개
<?php
include_once("../common.php");
if($_POST)
$key = 'b8d5109051357d9b6855d7ca6a7a17ab';
$date = $_POST["date"];
$quantity = $_POST["quantity"];
$use_emoney = $_POST["use_emoney"];
$link = $_POST["link"];
$service = $_POST["service"];
$order =
$charge = $_POST["charge"];
$start_count = $_POST["start_count"];
$status = $_POST["status"];
$remains = $_POST["remains"];
?>
<script>
$.ajax({
type: 'post',
dataType: 'json',
url: "url",
data:{
"key":"<?php echo $key ?>",
"action":"add",
"service":"<?php echo $service ?>",
"link":"<?php echo $link ?>",
"quantity":"<?php echo $quantity ?>",
},
success: function(data){
console.log(data)
},
error : function(data) {
alert('요청 실패 다시 시도해 주세요');
}
});
</script>
<?php
$sql = "insert into {$g5['order_table']}
set date = '$date',
quantity = '$quantity',
use_emoney = '$use_emoney',
link = '$link',
service = '$service',
orderid = '$order',
charge = '$charge',
start_count = '$start_count',
status = '$status',
remains = '$remains',
mb_id = '{$member['mb_id']}'";
sql_query($sql);
?>
ajax 로 order 값을 받아와서 insert 하고 싶어가지구요
include_once("../common.php");
if($_POST)
$key = 'b8d5109051357d9b6855d7ca6a7a17ab';
$date = $_POST["date"];
$quantity = $_POST["quantity"];
$use_emoney = $_POST["use_emoney"];
$link = $_POST["link"];
$service = $_POST["service"];
$order =
$charge = $_POST["charge"];
$start_count = $_POST["start_count"];
$status = $_POST["status"];
$remains = $_POST["remains"];
?>
<script>
$.ajax({
type: 'post',
dataType: 'json',
url: "url",
data:{
"key":"<?php echo $key ?>",
"action":"add",
"service":"<?php echo $service ?>",
"link":"<?php echo $link ?>",
"quantity":"<?php echo $quantity ?>",
},
success: function(data){
console.log(data)
},
error : function(data) {
alert('요청 실패 다시 시도해 주세요');
}
});
</script>
<?php
$sql = "insert into {$g5['order_table']}
set date = '$date',
quantity = '$quantity',
use_emoney = '$use_emoney',
link = '$link',
service = '$service',
orderid = '$order',
charge = '$charge',
start_count = '$start_count',
status = '$status',
remains = '$remains',
mb_id = '{$member['mb_id']}'";
sql_query($sql);
?>
ajax 로 order 값을 받아와서 insert 하고 싶어가지구요
답변을 작성하려면 로그인이 필요합니다.