WordPress Ajax


function ajax_listingGrid() {
	$_POST['current_offset'];
	
	$return['status'] = $_POST['current_offset'];
	echo json_encode($return);
        die(); 
}

add_action( 'wp_ajax_ajax_listingGrid', 'ajax_listingGrid' );
add_action( 'wp_ajax_nopriv_ajax_listingGrid', 'ajax_listingGrid' );

	$( ".pc_input_submit" ).click(function() { //2AM ON AND OFF

        var something           = $(this).attr("data-something");
       
 
		if (window.FormData) {
			formdata = new FormData();
			formdata.append("something", something);
			formdata.append("action", "ajax_listingGrid"); 
		}
		
		if (formdata) {
			$.ajax({
				url: '/wp-admin/admin-ajax.php',
				type: "POST",
				data: formdata,
				processData: false,
				contentType: false,
				success: function (res) {
				
					response = JSON.parse(res);
				

                    //alert(response.status);
                    //alert(response.amount);
                    $('.result_wrap').css('display','inline-block');
                    $(result_id).html(response.amount);
                    $('#explination_wrap').html(response.status);
                    
				
				}
			});
		}
        

	   
	}); //2AM ON AND OFF
Comments