propertyhive / WP-Property-Hive

The complete estate agency software plugin for WordPress
Other
27 stars 27 forks source link

Viewing Actions Meta Box not redrawing after Ajax call #123

Closed johnedwarddalton closed 4 years ago

johnedwarddalton commented 4 years ago

The Viewing Actions meta box is not redrawing once an action is pressed (e.g. EmailOwner Booking Confirmation or Viewing Carried Out. It seems as though the callback function is no longer being called once the AJAX call has been made, so that the redraw_viewing_actions function is not called. I suspect it's a problem with the changes to jQuery in WordPress 5.5 similar to the recent media loading issue.

Screenshot 2020-08-13 at 10 05 17
johnedwarddalton commented 4 years ago

Update: The issue seems to be that jQuery migrate is no longer included in WordPress 5.5. Because of this, the jQuery.post call to admin-ajax.php returns an error response instead of a success response, so that redraw_viewing_actions is not called. The reason that an error response is triggered is because the Ajax function (e.g. viewing_email_owner_booking_confirmation) is not returning any JSON data and a JSON Parse Error is invoked. Actually returning some JSON Data by, for example, adding echo '[]' just before the die() statement cures the issue. However, I'm not sure how many Ajax functions this affects so there may be a better solution.

johnedwarddalton commented 4 years ago

See this post as well: https://github.com/jquery/jquery/issues/3973

Changing the expected data type on the calling function to "text" from "json" also fixes the issue.

propertyhive commented 4 years ago

Thanks for reporting this. Just to confirm that a new version of Hive was released this morning at around 8am resolving these issues surrounding the changes to jQuery in WP 5.5.

Regards, Steve

johnedwarddalton commented 4 years ago

HI Steve, Unfortunately, the latest release (1.4.66) does not solve the issue with the Viewing Actions, as the jQuery.post() still specifies an expected return type of 'json' which causes a parse error.

propertyhive commented 4 years ago

You're absolutely right. Investigating now and will get a release out in the next hour. As soon as this is available I'll update this thread.

Steve

propertyhive commented 4 years ago

1.4.67 has been released which ensures a JSON response is made in AJAX requests where applicable.

Apologies for any inconvenience. Any further questions or issues regarding this please do let me know,

Steve