Identifying ajax request or browser request in grails controller

前端 未结 3 469
小蘑菇
小蘑菇 2021-02-04 04:52

I am developing a grails application which uses lot of ajax.If the request is ajax call then it should give response(this part is working), however if I type in the URL in the b

3条回答
  •  青春惊慌失措
    2021-02-04 05:33

    The normal method is to have the ajax routine add a header or a query string to the request and detect that. If you're using a library for the ajax, it probably provides this already.

    It looks like you're using prototype, which adds an X-Requested-With header set to 'XMLHttpRequest'; detecting that is probably your best bet.

提交回复
热议问题