New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Getting event.preventDefault(); to work?
Post Body

Not sure what I'm doing wrong here, the php script 'name.php' runs fine but it takes it away from the page - but using event.preventDefault() stops everything from running.

test_process.js

$('form#insert_template_form').on('submit', function(event) {
    event.preventDefault();
    var name = $('input#insert_template_name').val();
       $.post('ajax/name.php', {name: name}, function(data) {
           $('div#insert_data').text(data);
       });      
});

controlpanel.php (the relevant bit)

<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
</head>

<body>
<h2><u>Insert</u></h2>
<form action="ajax/name.php" name="insert_template_form" id="insert_template_form" method="post">
<textarea rows="10" cols="25" name="insert_template" id="insert_template"></textarea><br/>
Name your template: <input type="text" name="insert_template_name" id="insert_template_name"/><br/>
<input type="submit" name="insert_submit" value="submit" id="insert_submit"/></form>
<div id="insert_data"></div>

<script type="text/javascript" src="test_process.js"></script>
</body>
</html> 

Author
User Disabled
Account Strength
0%
Disabled 2 months ago
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
14,533
Link Karma
10,604
Comment Karma
3,929
Profile updated: 3 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
10 years ago