Support

Account

Forum Replies Created

  • Hi John.

    Thanks for your continued help! So my actual jQuery uses "this" to get the relavent row number. I’ve ben using :last as a temporary measure.

    var button = $('.rowId');
    
    	button.click(function(e){
    	
    	    var lastRowId = $(this).html();
    	    console.log('the last row ID ' + lastRowId);

    I wanting to call the repeater row with this newRowId inside my modal. I’ve been trying to get the newRowId in to my PHP as the repeater row number. Any ideas?

  • Hi John! Thanks for getting back to me! So I’ve created my JSON object and I can get it to log in the console. When I call the function on my page template I cant get the array to output. Any ideas what Im doing wrong? All Im wanting really is to be able to get the newRowId so can call a specific repeater row…

    jQuery

    jQuery(document).ready(function($) {
    	
    	var button 			= $('#ajax__button');
    
    	button.click(function(e){
    	
    	    var lastRowId = $('.rowId:last').html();
    	    console.log('the last row ID ' + lastRowId);
    	
    	
    		var ajaxurl = ajax_object.ajaxurl;
    		
    		var data = {
    		    'action': 'my_ajax_action', 
    		    'newRowId': lastRowId
    		};
    		
    		console.log('the data var ' + data);
    		
    		jQuery.post(ajaxurl, data, function(response) {
    		    json = jQuery.parseJSON(response);
    		    console.log(json);
    		});
    	});
    });	

    functions.php

    add_action( 'wp_ajax_my_ajax_action', 'my_ajax_action_callback' );
    add_action( 'wp_ajax_nopriv_my_ajax_action', 'my_ajax_action_callback' );
    function my_ajax_action_callback() {
        if(isset($_POST['newRowId'])){
        
            $response = array(
                'new_row_id' => $_POST['newRowId']
            );
            echo json_encode($response);
            exit;
        }
        else {
            echo "its null mannn";
        }
    }            
Viewing 2 posts - 1 through 2 (of 2 total)