WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The plugin I am working on has a table in the admin area with a single entry corresponding to single row. The admin has an option to perform certain actions on the table contents one of them being edit. All works well and the js script is as follows -



    var first_class = $(this).attr('class').split(" ")[0];
    var message = "message"+first_class;
    var content = jQuery("#"+message).text();
    var $dialog = $("<div></div>").html("<textarea style='width:99%; height:90%' class='popup-content'>"+content+"</textarea>").dialog({
        height: 400,
        width: 400,
        title: 'My Data',
        modal: true,
        autoOpen: false,
        dialogClass: 'wp-dialog',
        buttons: {
            "Save": function(){
                    type: "post",
                    url: script_data.admin_ajax,
                    data: {
                        action: "feedmng_update",
                        feed_id: first_class,
                        feed_msg: $(".popup-content").val()
                    error: function(xhr, status, error) {
                        console.log(xhr, error, status);
                    success: function(){

As can be seen, on clicking Save button, Ajax call is made to update the databse, which works well too.

Now I want to display a message that the database has been updated, but I cant seem to do it right. Here is the php code -

function feedmng_update(){

    global $wpdb;
    //$tablename = $wpdb->prefix. "feedmanager";
    $feedid = $_REQUEST["feed_id"];
    $feedmsg = $_REQUEST["feed_msg"];
    $wpdb->update( 'wp_feedmanager', array( 'message' => $feedmsg ), array( 'id' => $feedid ) );
    add_action( 'admin_notices', array( &$this, 'feedmng_edit_notif' ) );

function feedmng_edit_notif(){

    <div class="updated">
        <p><?php echo "Message succesfully edited"; ?></p>

Action hook for ajax -

add_action( 'wp_ajax_feedmng_update', array( &$this, 'feedmng_update' ) );

Is there a way to get it working ?

share|improve this question
Are you using the ajax action hooks to call the function feedmng_update? I dont see it here in the codes? – Maruti Mohanty Nov 15 '13 at 6:26
Yes I am, did not post it though ! – Navin Nagpal Nov 15 '13 at 7:25
It works (Ajax part involving DB update) all well. The only prob is with the custom message. – Navin Nagpal Nov 15 '13 at 7:39
ok so you have the ajax hook name and callback function name same – Maruti Mohanty Nov 15 '13 at 8:19
Included that too above to avoid confusion – Navin Nagpal Nov 15 '13 at 8:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.