주어진 필드들을 한 번에 처리하기 위해서는 객체를 사용하여 데이터를 구조화.
<input type="text" id="price">
<input type="text" id="qty">
<input type="text" id="title">
<input type="text" id="fullname">
<input type="text" id="memo">
<input type="text" id="file">
<input type="text" id="section">
<input type="text" id="category">
<!-- 필요한 만큼 필드를 추가할 수 있습니다 -->
$("form").submit(function(e) {
e.preventDefault();
var data = {
price: $("#price").val(),
qty: $("#qty").val(),
title: $("#title").val(),
fullname: $("#fullname").val(),
memo: $("#memo").val(),
file: $("#file").val(),
section: $("#section").val(),
category: $("#category").val()
};
$.ajax({
url: "includes/login.php",
method: "POST",
data: data,
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
}
});
});
'BackEND > PHP' 카테고리의 다른 글
json_encode()함수php에서 사용법 (0) | 2023.07.29 |
---|---|
ajax를 활용해서 데이타 전송하기. (0) | 2023.07.09 |
json_encode() : PHP의 데이터 구조를 JSON 문자열로 변환 (0) | 2023.07.01 |
PHP기본-세션에 대하여 (0) | 2023.05.28 |
PHP기본 - 쿠키에 대하여 (0) | 2023.05.28 |