Skip to content

Instantly share code, notes, and snippets.

@stankobrin
Created Aug 5, 2014
Embed
What would you like to do?
ajax call
// 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