I need to deal with these two cases differently, is there a good solution?
if ($_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { /* ajax request */ }
I can think of 2 ways to achieve this:
On the AJAX side, you can set your own HTTP header with XMLHttpRequest.setRequestHeader(), and then check for this header on the PHP side with getallheaders(), to indicate that the request was made by the AJAX client. If your php script does not find a custom header, you can consider it a non-AJAX request.
XMLHttpRequest.setRequestHeader()
getallheaders()
, querystring, . . http://example.com/process?ajax=true AJAX http://example.com/process?ajax=false AJAX.
Source: https://habr.com/ru/post/1732482/More articles:Good documentation / book about the future - javaHow to compare execution paths in .NET? - c #Add text to image - textThe Basics of Converting Nullable Values to a Nullable Type - c # -3.0using the rm command in a c program, using the system () function in stdlib.h - cNo result in the LINQ query provides a reference to an object that is not installed in the object instance in the IF ELSE statement - nullPixel chains from path length coding - pixelStored Procedure, Date and Time - c #intersection of two lines - matlabкак добавить строку/Удалить эффект строки в datagrid - flexAll Articles