Skip Navigation

[Resolved] jQuery(this) not work in ajax

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by kelvinL-2 1 year, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2523919
Screenshot 2022-12-29 at 12.12.55 AM.png
Screenshot 2022-12-29 at 12.12.10 AM.png

Dear Sir/Madam,

I have a View with many records, I create a button to get an element's attribute value but it caught error

jQuery(document).ready(function() { 
   jQuery(".register_member_facial").click(function () {
    console.log('The function register_member_facial is hooked up');
    jQuery.ajax({
        type: "POST",
        url: "/wp-admin/admin-ajax.php",
        data: {
            action: 'register_member_facial',
            // add your parameters here
            member_id: jQuery(this).attr('mid').val()
        },
        success: function (output) {
           console.log(output);
        }
        });
    });
});
#2524721

Hi,

Thank you for contacting us and I'd be happy to assist.

Can you please test the code after changing the part:


jQuery(this).attr('mid').val()

To:


jQuery(this).attr('mid')

This should do the trick.

regards,
Waqar

#2526277

My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.