php - Get div content value during print post data? -
i new wordpress , php , want div content data when print_r($_post)
i used add_action( 'save_post', 'wpse_save_meta_fields' );
wordpress hook save data or update data.
when print_r($_post)
things except selected_element_all div content.
how data or resolve ?
jquery code ( data file)
jquery(document).ready(function() { var postid = "<?php echo $post_id;?>"; jquery("#sel_all_mmy").click(function() { jquery.ajax({ data: { 'post_id': postid }, type: 'post', datatype: 'json', url: "<?php echo get_template_directory_uri();?>/get_all_make_model.php?", success: function(data) { jquery(".selected_element_all").append(data); } }); }); });
html div append data
<div class="selected_element_all" style="font-size:15px"> </div>
and php code used
<?php function wpse_save_meta_fields( $post_id ) { global $wpdb; echo "<pre>"; print_r($_post); exit(); } add_action( 'save_post', 'wpse_save_meta_fields' ); ?>
try way
take input hidden field in div like
<input type=hidden name="my_val" class="my_val" value=""> </div>
then use in jquery script like
jquery(document).ready(function(){ var postid ="<?php echo $post_id;?>"; jquery("#sel_all_mmy").click(function(){ jquery.ajax({ data:{'post_id':postid}, type:'post', datatype: 'json', url: "<?php echo get_template_directory_uri();?>/get_all_make_model.php?", success: function(data){ jquery(".selected_element_all").data(data); jquery(".my_val").val(data); } }); }); });
and print_r value in php function print_r($_post['my_val'])
;
i hope it's working.
Comments
Post a Comment