stankobrin
8/5/2014 - 5:57 AM

ajax call

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 = '';
 
}