Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PROBLEM Correct way to post form data in ajax
#7
@vish93

If you are going to do it with your own plugin (which would indeed be better than in the theme folder),
GS provides some functions for handling AJAX together with auth (requestIsAjax, get_cookie, and check_nonce)

I do AJAX saving in my plugin Components Extended (see my signature below), you can look at the code for inspiration, see this excerpt for example:

PHP Code:
$global $USR;
if (
requestIsAjax()) { 

 
 // protect against CSRF, basic check
 
 if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME')) 
 
   die();

 
 // only continue if the request comes from the same domain & nonces match
 
 if (empty($_GET['nonce']) || !check_nonce($_GET['nonce'], 'components_ext_action''components_ext.php'))
 
   die();

Reply


Messages In This Thread
Correct way to post form data in ajax - by vish93 - 2019-03-05, 08:18:43
RE: Correct way to post form data in ajax - by Tyblitz - 2019-03-07, 09:26:06



Users browsing this thread: 1 Guest(s)