[wp-trac] [WordPress Trac] #31577: wp.ajax.send JS function should send ajax request with dataType json
WordPress Trac
noreply at wordpress.org
Tue Mar 10 02:18:50 UTC 2015
#31577: wp.ajax.send JS function should send ajax request with dataType json
--------------------------+------------------------------
Reporter: TikiTDO | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
--------------------------+------------------------------
Comment (by TikiTDO):
Replying to [comment:2 nacin]:
> I believe what needs to happen is `Content-type: application/json` needs
to be returned, correct? If you are using the corresponding PHP API
(`wp_send_json_success()/_error()`), then you should always have this
content type set.
Logically, yes. However, this was happening to a client when they were
trying to add an image to a post, even after I had disabled all plugins.
Perhaps there might be a deeper root cause, but I found that the attached
fix was sufficient for this scenario.
Given that the function in question only deals with JSON responses I
figured it would be a good idea to get this in place, that way even if
something goes wrong higher up the chain there is still a chance to
recover from it. Otherwise I would like to spare a less experienced
developer a painful multi-hour bug hunt.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31577#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list