worldofjr worldofjr - 9 months ago 82
Ajax Question

Permission denied to access property 'type'

I have a form that is being handled with jQuery for an AJAX request, and I'm getting an error in the console;

Error: Permission denied to access property 'type'

in the
file on line 5, col 3395.


<script language="javascript">
(document).ready(function() {
$('#emvForm').submit(function(event) {
var email, nm;

email = $('#emailfield').val;
nm = $('#namefield').val;

if (email != '' && nm != '') {
type: 'post',
url: '/ajax/enewsletter_subscribe',
data: {
'email': email,
'name': nm,
success: function(data) {
$('#form-nlfm').slideUp(200).html('<h2>Thank You</h2><p class="text-center">You are now signed up to our mail list.</p>').slideDown(500);


<form accept-charset="utf-8" action="" id="emvForm" method="POST" name="emvForm" role="form" target="_top">
<div class="result"></div>
<div class="form-area col-xs-10 col-xs-offset-1" id="form-nlfm">
<div class="form-group"><input class="form-control" id="namefield" name="name" placeholder="Your Name" size="30" type="text" value="" /></div>
<div class="form-group"><input class="form-control" id="emailfield" maxlength="64" name="email" placeholder="Your Email Address" size="30" type="text" value="" /></div>
<p class="text-center"><button id="nlfm-submit" class="submit button">Subscribe</button></p>

I've tried changing selectors, renaming variables, and other similar things.


Where you have this:

email = $('#emailfield').val;
nm = $('#namefield').val;

It should be this, because jQuery's val is a function:

email = $('#emailfield').val();
nm = $('#namefield').val();