# wpjam-basic/trunk/static/ajax.js

WPJAM Basic, version trunk. 39 lines.

- Page: https://pluginprobe.com/plugins/wpjam-basic/trunk/code/static/ajax.js
- Raw: https://pluginprobe.com/plugins/wpjam-basic/trunk/raw/static/ajax.js
- Modified: 2024-07-29T02:26:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpjam-basic/trunk/code/static/ajax.js#L10-L20`.

```javascript
jQuery(function($){
	if(window.location.protocol == 'https:'){
		ajaxurl	= ajaxurl.replace('http://', 'https://');
	}

	$.fn.extend({
		wpjam_submit: function(callback){
			let _this	= $(this);
			let data	= new FormData(_this[0]);

			data.set('_ajax_nonce',	$(this).data('nonce'));
			data.set('action',		$(this).data('action'));
			data.set('defaults',	$(this).data('data'));
			data.set('data',		$(this).serialize());

			$.ajax({
				type: 'POST',
				url: ajaxurl,
				data: data,
				processData: false,
				contentType: false,
				success: function(data){
					callback.call(_this, data);
				}
			});
		},
		wpjam_action: function(callback){
			let _this	= $(this);

			$.post(ajaxurl, {
				_ajax_nonce:	$(this).data('nonce'),
				action:			$(this).data('action'),
				data:			$(this).data('data')
			},function(data, status){
				callback.call(_this, data);
			});
		}
	});
});
```
