Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PROBLEM Correct way to post form data in ajax
#8
(2019-03-07, 09:26:06)Tyblitz Wrote: @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();


Thank you ever so for the response. I am going to use the plugin for storing/keeping track of responses from the form. For the ajax post where should I be point the url to?
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 vish93 - 2019-03-07, 19:50:58



Users browsing this thread: 1 Guest(s)