I have this bit of JQuery ` function

I have this bit of JQuery

function saveLocation_save_changes() {
	 alert("aa");
	 alert($('#post_id').val());
	 alert($('#website').val());
        $('.gmw-yl-tab').removeClass('active');
        $('#gmw-yl-address-tab').addClass('active');
        $('.gmw-yl-tab-wrapper').hide();
        $('#gmw-yl-address-tab-wrapper').show();

    	$("#gmw-yl-spinner").show();
    	$('#gmw-yl-get-latlng, #gmw-yl-get-address').removeClass('changed');

    	if ( $('#gmw-yl-update-location').hasClass('update') ) {
    		$('#gmw-yl-form').slideToggle();
    	}
    	$('#gmw-yl-update-location').removeClass('update');
    	 var args = {};
		$.ajax({
			type       	: "post",
			data  		: {action:'gmw_f2_update_listing_location', 'post_id': $('#post_id').val(), 'post_type': $('#post_type').val(), 'post_title': $('#post_title').val(), 'address': $('#gmw-yl-autocomplete').val(), 'phone': $('#phone').val(), 'alternative_phone': $('#alternative_phone').val(), 'email': $('#email').val(), 'website': $('#website').val()},
			url        	: ajaxurl,
			error:function(data){
				alert(data);
				alert("ddd");
			},
			success:function(data){
				alert("bb");
				setTimeout(function() {
					$("#gmw-yl-spinner").hide();

					$("#gmw-yl-message p").html(data);
					$("#gmw-yl-message").fadeToggle(function(){
						setTimeout(function() {
							$("#gmw-yl-message").fadeToggle();
						},2500);
					});

   				},500);
				alert("qq");
				$("#dr_update_form").submit();
				alert("rr");
			}
		});
		alert("cc");
		return false;
 	};

Called by

$('#save_changes').click(function() {

		return saveLocation_save_changes();
	});

When I click on "Save Changes" on the update-listing page gmw_f2_update_listing_location work OK and the location, phone etc gets stored in the database but the Practice Name, fee etc doesn't when $("#dr_update_form").submit(); is called. I suspect add_action( 'template_redirect', array( &$this, 'handle_page_requests' ) ); isn't being actioned but I don't know what I need instead. Thanks

  • Johanna
    • The Incredible Code Injector
    function gmw_f2_update_listing_location() {
    		include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
    
    		if ( function_exists( 'gmw_pt_update_location' ) ) {
    			//setup geocoder args
    			$args = array(
    					'post_id'         => $_POST['post_id'],
    					'post_type'       => $_POST['post_type'],
    					'post_title'      => $_POST['post_title'],
    					'address'         => $_POST['address'],
    					'additional_info'  => array( 'phone' => $_POST['phone'], 'fax' => $_POST['alternative_phone'], 'email' => $_POST['email'], 'website' => $_POST['website'] )
    			);
    			//run geocoder function
    			gmw_pt_update_location( $args );
    		}
    		echo __( 'Location successfully saved! ', 'GMW' );
    		die();
    	}
    	add_action('wp_ajax_gmw_f2_update_listing_location', 'gmw_f2_update_listing_location');

    Sorry - I didn't think you needed this bit as the location is getting stored OK

  • Vinod Dalvi
    • WP Unicorn

    Hi Johanna,

    Thank you for your reply.

    I want to see this code to check any conflict issue.

    I also want to test it on your site so i requested you to share update-listing page link in my previous reply so could you please share it if you can?

    Would you mind if I logged in to your site and did some testing? This might help get to the bottom of this faster. If this is ok, just grant me temporary admin access to your site by clicking "Grant Access" button in the WPMU DEV Dashboard Settings as described on the following page and reply on this thread after granting it?

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Regards,
    Vinod Dalvi

  • Vinod Dalvi
    • WP Unicorn

    Hi Johanna,

    I tried to access your site using support staff access but got the following error message.

    Sorry, this is an invalid access token. You must ask the user to grant access.

    Please revoke and regrant me support staff access or just send log in info through our secured contact form: https://premium.wpmudev.org/contact/
    - Choose "I have a different question"
    - Include my name in the subject "Vinod Dalvi"
    - Include the URL of this post in your message so that I may track this issue better
    - Include login information (Wordpress admin info username + password )

    I just noticed one thing the directory "Save Changes" button in the front end is generated using the following markup

    <input type="submit" value="Save Changes" name="update_listing">

    But as you have shared you are using the following code

    $('#save_changes').click(function() {
    
    		return saveLocation_save_changes();
    	});

    So have you added the "save_changes" id to the button or anything else?

    Regards,
    Vinod Dalvi

  • Vinod Dalvi
    • WP Unicorn

    Hi Johanna,

    Thank you for sending me the site details but you have just sent me the admin password and not the user name.

    Could you please send me all the details and also answer all the questions asked in my previous reply like following that will help us to get to the bottom of this faster?

    So have you added the "save_changes" id to the button or anything else?

    Regards,
    Vinod Dalvi

  • Vinod Dalvi
    • WP Unicorn

    Hi Johanna,

    I accessed your site and troubleshooted it.

    To store the Practice Name try using the following code by replacing it in your shared code in your question on line number 21

    data : {action:'gmw_f2_update_listing_location', 'post_id': $('#post_id').val(), 'post_type': $('#post_type').val(), 'post_title': $('.standard-form #title').val(), 'address': $('#gmw-yl-autocomplete').val(), 'phone': $('#phone').val(), 'alternative_phone': $('#alternative_phone').val(), 'email': $('#email').val(), 'website': $('#website').val()},

    To store the fee you have to pass the value contained in the Fees field to the AJAX function gmw_f2_update_listing_location and then in that function you have to pass this value as an argument to the function gmw_pt_update_location which i suppose contains the code to store the fess but if not then you will have to develop custom code in the function gmw_pt_update_location to store Fees value.

    Best Regards,
    Vinod Dalvi

  • Johanna
    • The Incredible Code Injector

    O dear I think you have misunderstood my question. The gmw location fields are getting stored ok. The problem is the rest of the fields aren't getting stored in the correct tables when the JQuery does the submit() even thought the form is being submitted. Anyway you have just given me an idea of how to get round the problem which I will try before Monday.

  • Vinod Dalvi
    • WP Unicorn

    Hi Johanna,

    I think you misunderstood my reply.

    I am not talking about the location fields but the function gmw_f2_update_listing_location that you call in your AJAX call to save the fields value.

    It seems from your shared code that you have not developed code to save rest of the fields like Fees.

    Regards,
    Vinod Dalvi

  • Johanna
    • The Incredible Code Injector

    Hi Vinod

    Some of the fields such as Location. telephone, website are a standard part of the GMW (Geo My Wordpress) data. These are all being stored successfully. The other fields such as fees, duration etc. are custom fields defined in custompress. I would expect the Directory plugin code to take care of these

    Johanna

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.