How Can I work with form and ajax without an extern php file
Dear All,
I am trying hard to update my localStorage variable.
I need to delete a localStorage variable after a from is submited. My form is wihtin a dialog page.
When I click a button, it opens a dialog box to confirm the deletion.
Here is my form:
- <div data-role="dialog" id="supprimer">
<div data-role="header" data-position="fixed">
<h1>Supprimer</h1>
</div>
<div data-role="content">
<h4>Etes-vous sûre e vouloir supprimer ce module?</h4>
<form id="JSON-formSupprimer" method="post" data-ajax="true">
<label for="moduleId">@pseudo</label>
<input type="hidden" id="moduleId" name="moduleId" value="222"><br><br>
<label for="save_supp"></label>
<input type="submit" id="save_supp" name="save_supp" value="Supprimer">
</form>
</div>
</div>
When it submited, I would like to have this dialog box still displayed.
I also have a script which will delete de localStorage:
- $(document).live('pageinit', function(e){
$("#JSON-formSupprimer").submit(function() {
var formData = $(this).serialize();
alert(formData);
// Here will be the code to delete the localStorage variable
});
})
The problem is that nothing happen and I got an error message
Timestamp: 07.10.12 01:22:01
Error: uncaught exception: cannot call methods on listview prior to initialization; attempted to call method 'refresh'
I also observed if I add a php file in action="", the above error message desapear.
I am new with jQuerymobile and I would like to know if someone can tell me how to setup that form for the best.
I think I am close to the result, but something should be wrong.
Many thank for your help.
Cheers