php


Submitting bootstrap form via Ajax passes wrong parameters


I've built a data entry page using Bootstrap and I'm trying to process it via Ajax/jQuery. When I click the Submit button, though by tracing, I can see my ajax method is called, what gets sent isn't the right thing at all.
Here's an excerpt of the HTML, showing only one text control plus the button. The real page has a lot more controls:
<form role="form" id="addform" name="addform" class="form-horizontal">
<div class="form-group">
<label class="col-form-label col-md-offset-1 col-md-1" for="actiontitle">Action title</label>
<div class="col-md-9">
<input type="text" class="form-control" id="actiontitle" name="actiontitle" placeholder="Action title" required>
</div>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button type="submit" "btn btn-default" id="submit" name="submit">Submit</button>
</div>
</div>
</form>
The Ready function includes this code:
$('#addform').submit(function(event){
saveAction();
event.preventDefault();
});
Here's the key piece of the saveAction function. There's code above this that populates the fnargs variable:
$.ajax({
url: 'retrievedata.php',
type: "POST",
async:false,
data: {"functionname":"getdata", "arguments":fnargs},
dataType: "JSON",
success: function (obj) {
alert('Your action has been submitted and will be reviewed. Thanks for adding to Acts of Conscience');
$('addform').each(function(){
this.reset;
});
},
error: function(textStatus, errorThrown) {
success = false;
alert('We were unable to add your action. Please try again.');
}
})
When I click the button, what gets sent is something like this:
http://www.XXXXXX.com/addacts.php?actiontitle=The+data+I+typed+in&submit=
That is, it calls the same page rather than the page specified in the Ajax call.

Related Links

Laravel 5 migration error
Check table exists
How to replace reference to element with its value?
Execute a PHP method one time
Delete some files in folder
Joomla site behind login, images folder is accessible
Update a field multiplying another field and a constant in sql with php [closed]
PHPUnit Post request for a Symfony2 controller
Constants using define() in Laravel 5
How to extend the “album” model to return other objects from the database?
cURL PHP download file to user not to server
Random image from directory with no repeats?
How to retrieve attempted $_SERVER['REMOTE_USER'] from URL when no authentication is required
laravel get last related model
mysql removed character encoding of text
Noob PHP form logic questions

Categories

HOME
mod-rewrite
svn
list
typelite
functional-programming
windows-8.1
openxml
iverilog
bing-search
apache-kafka-connect
jint
google-search-console
chromecast
cuba-platform
corona
phonegap-build
pywinauto
reselect
android-5.1.1-lollipop
jqxgrid
hidden
xsl-fo
unity-container
pst
coreldraw
connection-refused
ava
cell
restier
software-packaging
ratio
web-config-transform
acrobat
annotation-processing
javax.persistence
fusion
nic
es6-modules
instructions
vcenter
lxml
adminer
keyboard-layout
stackpanel
fastlane
cloudera-quickstart-vm
unification
xll
suds
viewcontroller
hypothesis-test
julius-speech
reverse-dns
axis
adblock
section508
swift2.3
brightscript
comm
renderman
spring.net
maven-jaxb2-plugin
sequence-diagram
winmerge
kendo-editor
controllers
yui3
s-function
tablespace
logical
ndk-build
openseadragon
piping
simian
exists
i2b2
psd
odesk
cryptojs
place
cfwheels
dynamics-ax-2012-r2
android-audiomanager
hp-idol-ondemand
rubber
image-rotation
adwords-apiv201402
wso2bam
radius-protocol
profiles
meteorite
django-facebook
eager-loading
jbox2d
android-authenticator
oembed
word-frequency
gamesalad
prefuse
liveconnect
background-repeat
radscheduler
nosetests
simile
bass
chunking
ntruencrypt
motif

Resources

Encrypt Message