X-Requested-With header not set in jquery ajaxForm plugin

后端 未结 5 1613
余生分开走
余生分开走 2020-12-05 19:32

I\'m using the jQuery ajaxForms plugin to make an ajax submit to my CakePHP app.

Cake\'s RequestHandler detects ajax requests by looking at the \"X-Requested-With\

5条回答
  •  执念已碎
    2020-12-05 20:33

    @Nicky De Maeyer's answer to his own question

    Actually you don't need to do this yourself (appending a hidden input field).

    AFAIK you can just pass such data to ajaxForms plugin in the options object

    $('#myForm1').ajaxForm({data:{"X_REQUESTED_WITH":"XMLHttpRequest"}});
    

    Should automagically (in the hidden iframe file upload case) append such an input to your form on submission

    
    

提交回复
热议问题