what I am doing is creating a form using JSON, this form can then be edited and create a new JSON object. The problem I am facing is getting the form id. The code I use to return a JSON object:
form = document.forms[0];
$.fn.serializeObject = function()
{
alert("start serializeObject");
var o = {};
var a = this.seralizeArray();
$.each(a, function(){
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
alert(o);
};
$(function() {
alert("here");
form.submit(function(){
result.append(JSON.stringify(form.serializeObject()));
return false;
});
});
It is just a refresh page. I'm not sure why. This program is not located on the server and is not used on the server. By this, I mean that only everyone will be running locally on the local machine without installing apache2.
Thank.
source
share