So, I have following for ajax:
//Ajax
jQuery(document).ready(function() {
jQuery('.my_popup_contact_open').click(function(e) {
e.preventDefault();
jQuery.ajax({
type: "GET",
url: "<?php echo admin_url('admin-ajax.php'); ?>",
dataType: 'html',
data: ({ action: 'rh_contact_form_support'}),
success: function(data){
jQuery('.rhm_contact_support').html(data);
},
error: function(data)
{
alert("Error!");
return false;
}
});
});
});
For my my_js.js file, I have following setup:
//header script:
(function ($, root, undefined) {
$(function () {
'use strict';
//js goes here
// Default line End
});
})(jQuery, this);
When I put the ajax js in the my_js.php, the function does not work. It only seems to work when I put the code inline at the bottom of php page.
Any suggestions to why it does not work when it is placed in "my_js.js"?
Thanks!