You use globals 🙁 whenever you think that you need to use a global you should automatically stop coding and invest as much time as it takes to remove that need.
In your case it seems like you assume that global variables persist between Ajax request, but they don’t. In addition your design of the code is broken as in client server configuration you can not assume that the server state remain the same between request, therefor when you need to do some operation you need to do it in one request and not to split it into 3. It is good design to let the user know that he can not perform an operation, but you need to actually recheck all conditions when getting to actually performing the operation even if you checked them when you displayed the UI to the user.
Related Posts:
- What is content-type and datatype in an AJAX request?
- How to send multiple data fields via Ajax?
- Adding an onclick function to go to url in JavaScript?
- When and why to ‘return false’ in JavaScript?
- Download File Using jQuery
- Jquery Ajax Posting JSON to webservice
- How is JavaScript .on() method defined?
- correct way of comparing string jquery operator =
- Jquery to change form action
- Split string in jquery
- How can I expand and collapse a using javascript?
- Detecting value change of input[type=text] in jQuery
- Javascript : array.length returns undefined
- Comparing dates in jquery
- Slide right to left?
- How do I send this form's output to a new WordPress page?
- Annoying “JQMIGRATE: Migrate is…” in console after update to WordPress 4.5
- Update jquery version
- Correct Method to run scripts with dependencies without enqueue?
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- How to get a jQuery script to run on a page?
- Modify Custom Field in Media Library using JavaScript
- Loading jQuery With Two Fallbacks
- Moving jQuery to the footer without using de-register in WordPress
- Best approach for loading a sidebar Only if the screen max-width is >900px?
- Including jQuery in WordPress
- Comment form vaildation
- Enqueuing jQuery in plug-ins
- Prevent five different copies of jquery from being included on every page
- Script doesn’t load because of a javascript MIME type error
- javascript is not working on Event Submission?
- TinyMCE – TypeError: r is undefined
- WordPress audio player causing js error, mediaelementplayer is not a function
- Auto-detect javascript errors and warn theme user
- combining js scripts from a js newb [closed]
- Heartbeat API: How to access data already enqueued?
- How to get a value from PHP in Jquery through Ajax
- Script for initializing JQuery Masonry for WordPress
- How to stop focus() in custom js from scrolling to footer?
- Getting post meta in the flex slider
- Correct way to write jQuery functions in WordPress
- Removing jQuery from footer
- Use jQuery to conditionally hide elements in Quick Edit
- AJAX Loaded Glossary like Search results with links to other entries from custom table
- WordPress jquery files not being enqueued
- Trouble with WordPress Ajax Login System – 302
- Load the next posts ajax
- jQuery code not working in widgets page
- Load random posts without refreshing page (jQuery)?
- How to use jquery included with wordpress for jpanelmenu
- Cannot get Jquery to work with wordpress
- Problem getting .js file to load via a plugin
- Using jquery-1.7.2.min.js instead of the wordpress jquery
- WordPress error when replacing local jQuery by externally-hosted
- Adding jQuery UI elements to WordPress page
- Create special WordPress slideshow with “jquery.cycle.all.js”
- Jquery UI Google CSS, from where?
- datepicker for custom post type admin
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- How to add plugin with jQuery to custom theme?
- jQuery selectable() function won’t work in wordpress
- jQuery(selector) vs. $(selector)
- Null/undefined return in WordPress AJAX request
- Manipulate retrieved ajax data in php
- Disable auto hide of the login form on Woocommerce’s checkout page
- WordPress Front-End Theme Editor
- Sorting dynamic table content with jQuery
- jQuery .load and WP function
- Bootstrap and jQuery error: $ is not defined
- Fire action after enqueue script
- Auto next upon clicking image without clicking Next button
- How can I get this menu container to be the height of the contents?
- JQuery is not working after complete load of the page
- Carousel Slider For Custom PHP Snippet Is Not Working
- why does so many javascript libraries are loaded along with my website?
- Why does my media selection script write to ONLY the first input field?
- Add a jQuery snippet for sepcific user role
- Show/Hide text after the first paragraph
- How to specify url for ajax call in wordpress plugin
- Call admin ajax using absolute url? Relative URL breaks (frontend ajax)
- Dynamic image grid gallery
- Responsive framework – edit child js
- Check with jQuery value of checkbox from custom admin panel
- JS script not being included [closed]
- jquery issue in functions.php
- WooCommerce – PrettyPhoto appending URL with #prettyPhoto
- Are you sure popup on Contact Form 7 [closed]
- change the icon of a custom post type in WordPress to use twitter boostrap
- Using jQuery toggle() in WordPress post to show/hide Tweet button?
- Call a Simple JQuery from within Flash
- Ajax request with jQuery without WP_ajax
- Change image on post title hover (more than one instance) – Jquery
- How to fire jQuery after $(window).on(‘load’)
- JQuery WordPress gallery [closed]
- JS file not loading [closed]
- How can insert JQuery in WordPress? [closed]
- Jquery in IE, fully messed up
- Theme variation conflict with jquery select2 dropdown
- Contact Form 7 – Submit Form not working After Ajax Request [closed]
- Making the Google Maps API non readable