...

View Full Version : jQuery Autosave plugin... can't get it to work



devGOD
10-11-2010, 03:25 PM
jQuery Plugin: http://plugins.jquery.com/project/autosave

I've been trying for 3days to get this plugin to work, I've contacted the developers and no response. the demo on the site seems to work with a json output but the downloaded code & example does not work. I'm trying to get it to work with PHP as the backend and nothing. The instructions are very vague like a lot of jquery plugins. Are there any developers or experience jquery plugin users that can assist with telling me how to get this plugin to work correctly?

thanks in advance

Usage:

To simply autosave a form to its action url its simple:
$("form#myForm").autosave();
This shows the various options you can pass in to autosave:




$("input").autosave({
// Defaults to parent form url or window.location.href
url: url,
// Defaults to parent form url or get
method: "post",
// Defaults to false. Whether all "input" should be sent in the request or only the one it was triggered upon
grouped: true,
success: function(data) {
console.log(data);
},
// Defaults to JSON, but can be XML, HTML and so on
dataType: "json",
send: function() {
// Do stuff while we wait for the ajax response, defaults to doing nothing
console.log("Saving");
},
error: function(xmlReq, text, errorThrown) {
// Handler if the ajax request fails, defaults to console.log-ing the ajax request scope
console.log(text);
}
});

SB65
10-11-2010, 04:36 PM
Just tried this myself. I created a simple form which retrieves data from a mySQL DB via PHP, and calls a separate PHP function to update the database on save. Then I attached the autosave to the input fields and it works fine - have a look here (http://simonbattersby.com/demos/autosave_demo.php) if it helps.

Can you post your code?

EDIT: Ah, this fine in FF, but not in IE....or Chrome. Hang on.....
EDIT AGAIN: Sorry, my fault, permissions and things. It does work in IE and Chrome now.

devGOD
10-11-2010, 08:44 PM
Just tried this myself. I created a simple form which retrieves data from a mySQL DB via PHP, and calls a separate PHP function to update the database on save. Then I attached the autosave to the input fields and it works fine - have a look here (http://simonbattersby.com/demos/autosave_demo.php) if it helps.

Can you post your code?

EDIT: Ah, this fine in FF, but not in IE....or Chrome. Hang on.....
EDIT AGAIN: Sorry, my fault, permissions and things. It does work in IE and Chrome now.

wow how did you get that to work? you are good. i just have a basic test form with checkbox, drop down select, input and textarea. can you test to see if that works with those options. if you can post your code that would be great I oh you big time, i've been looking all over for help.


EDIT: i used your example to try and make one with all the boxes. what am i doing wrong?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css" media="screen">
*{margin:0;padding:0}
body{font-family:Arial, Helvetica, sans-serif;color:#666666}
h1{margin:20px}
p#message{clear:left;margin-left:50px;margin-top:30px}
form{margin-left:50px;width:400px}
label{float:left;width:350px;clear:left;margin-bottom:10px}
#name,#email{width:100px;margin-left:20px}
fieldset{padding:10px}
</style>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery.autosave.js"></script>
<script type="text/javascript">
$(function() {
$("input, select, textarea, checkbox, radio").autosave({
url: "autosave2.php",
method: "post",
grouped: true,
success: function(data) {
$("#message").html("Data updated successfully");
},
send: function(){
$("#message").html("Sending data....");
},
dataType: "html"
});
});
</script>

<title>jQuery autosave demo</title>
</head>

<body>
<h1>jQuery autosave demo</h1>
<form action="autosave.php" method="post">
<fieldset>
<label for="name">Name:<input type="text" name="name" id="name" value="Alan"/></label>
<label for="email">Email:<input type="text" name="email" id="email" value="alan@test.com" /></label>
<input name="id" type="hidden" value="1" />
<label for="radios">Radio Test:<input checked="checked" name="Radio1" type="radio" />
<input name="Radiotest" type="radio" /></label>
<label name="chktest">Checkbox: <input name="Checkbox1" type="checkbox" /></label>
<label name="testdrop">Test Drop:<select name="Select1">
<option value="test1">test</option>
<option value="test2">test2</option>
</select></label> <br />
<input type="submit" value="Save changes" />

</fieldset>
</form>
<p id="message"></p>


</body>
</html>

SB65
10-12-2010, 09:08 AM
Replied by PM.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum