데이터는 JSON 또는 일반 POST를 통해 보낼 수 있습니다. 다음은 JSON을 통해 전송된 데이터를 보여주는 예입니다 -
var value_1 = 1;
var value_2 = 2;
var value_3 = 3;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "your_url_goes_here",
data: { data_1: value_1, data_2: value_2, data_3: value_3 },
success: function (result) {
// perform operations here
}
}); 일반 포스트에서는 아래 코드를 사용할 수 있습니다 -
$.ajax({
type: "POST",
url: $('form').attr("action"),
data: $('#form0').serialize(),
success: function (result) {
// perform operations here
}
}); 위의 코드에 대한 대안이 아래에 설명되어 있습니다. -
data:'id='+ID & 'user_id=' + USERID,
with:
data: {id:ID, user_id:USERID}
so your code will look like this :
$(document).ready(function(){
$(document).on('click','.show_more',function(){
var ID = 10;
var USERID =1;
$('.show_more').hide();
$('.loding').show();
$.ajax({
type:'POST',
url:'/ajaxload.php',
data: {id:ID, user_id:USERID},
success:function(html){
$('#show_more_main'+ID).remove();
$('.post_list').append(html);
}
});
});
});