Skip to content

Instantly share code, notes, and snippets.

@snoise
Created April 10, 2014 14:22
Show Gist options
  • Save snoise/10387725 to your computer and use it in GitHub Desktop.
Save snoise/10387725 to your computer and use it in GitHub Desktop.
Ajaxに対応させるための外部javascript(一般)
(function($) {
$(document).ready(function(){
$('#loadingmessage').hide();
$('#res').hide();
$(document).on('click','#contactSubmit', function(){
$('#loadingmessage').show();
$('#res').hide();
$.post(
paka3Contact.ajaxurl,
{
action : 'paka3_action',
security : paka3Contact.security,
paka3_title : $("#i_t").val() ,
paka3_contents : $("#i_c").val()
},
function( response ) {
console.log( response );
$("#res").html("<strong>「"+response.title+"</strong>」は送信されました");
$('#loadingmessage').hide();
$('#res').show();
}
);
return false;
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment