2
First of all, in your jquery event handler the action parameter's value should be the string after wp_ajax_ and wp_ajax_nopriv_. So in your example the action should be update_records. So display_func is wrong.
Then in line 3 of your php code here the echo keyword should be removed.
So your php code should be like this:
function update_records(){
global $...
1
Searching for .notice on WP source code I found the culprit at wp-admin/js/common.js:
$( 'div.updated, div.error, div.notice' ).not( '.inline, .below-h2' ).insertAfter( $headerEnd );
Adding an inline class to my code solves the issue:
<div class="notice updated inline">Form sent</div>
1
I see that there's an internal server error (see screenshot) when you tried to update a record in the database, and the error is likely because you incorrectly called $wpdb->update() which has the syntax of — and note that the first three parameters ($table, $data and $where) are required:
wpdb::update( string $table, array $data, array $where, array|...
1
I want the URLs of the nav-items to be replaced with #
You can use the nav_menu_link_attributes hook to set the custom href value like so:
add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) {
if ( 'menu-categorias' === $args->theme_location && 'category' === $item->object ) {
$atts['href'] = '#' . ...
1
/* Show/Hide my div*/
jQuery(document).on('click','.my-button',function() {
//jQuery('.div-wordpress').slideToggle('230','swing','hide');
this.remove();//supposed to be #my-button ?
});
Note that I have swapped ids for classes and just made a small JS update - this is the clicked element inside a jQuery event - not jQuery(this)
Here is a CodePen: ...
1
Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written.
jQuery(document).ready(function() {
// Some Code Goes Here...
})
Just take a look at the complete segment:
public function doSomethingSpecific() {
?>
<script type="text/javascript" >
...
1
In PHP, it's not necessary to post to a PHP file, it is only required to include ( or require ) files and then use checks and validations to ensure that code is only processed when required.
You simply need to include the PHP file as part of your application - it will process the PHP is the conditions are met.
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
jquery × 2247ajax × 539
javascript × 506
php × 346
plugins × 233
wp-enqueue-script × 180
functions × 156
plugin-development × 154
theme-development × 96
css × 80
jquery-ui × 78
html × 61
forms × 58
woocommerce-offtopic × 57
customization × 56
wp-admin × 56
posts × 53
custom-post-types × 46
widgets × 45
menus × 43
shortcode × 40
wp-query × 38
admin × 36
metabox × 36
images × 34