Skip to content

Instantly share code, notes, and snippets.

@stankobrin
Created August 10, 2014 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stankobrin/f92d23fa094857176452 to your computer and use it in GitHub Desktop.
Save stankobrin/f92d23fa094857176452 to your computer and use it in GitHub Desktop.
apf.js
// JavaScript Document
function apfaddpost(posttitle,postqty,postlink,postcode,postdesc,postprice) {
jQuery.ajax({
type: 'POST',
url: apfajax.ajaxurl,
data: {
action: 'apf_addpost',
apftitle: posttitle,
apfqty: postqty,
apflink: postlink,
apfcode: postcode,
apfdesc: postdesc,
apfprice: postprice,
},
success: function(data, textStatus, XMLHttpRequest) {
var id = '#apf-response';
jQuery(id).html('');
jQuery(id).append(data);
resetvalues();
},
error: function(MLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
function resetvalues() {
var title = document.getElementById("apftitle");
title.value = '';
var content = document.getElementById("apfqty");
content.value = '';
var content2 = document.getElementById("apflink");
content2.value = '';
var content3 = document.getElementById("apfcode");
content3.value = '';
var content4 = document.getElementById("apfdesc");
content4.value = '';
var content5 = document.getElementById("apfprice");
content5.value = '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment