JSON.parse
is the opposite of JSON.stringify
JSON.parse(String)
var str = '{"hello":"world"}';
var obj = JSON.parse(str);
console.log(obj.hello); // world
JSON.stringify(Object)
var obj = ...;
var json = JSON.stringify(obj);
var obj2 = JSON.parse(json);
Jquery Submit
1. //prepare a handle first
$('#formID').submit(function(event) {
//JQuery - getting submit data form
var values = {};
$.each($('#formID').serializeArray(), function(i, field) {
values[field.name] = field.value;
console.log(field.name+"\t"+values[field.name]);
});
}
2. //subimit form
$('#formID').submit();
JQuery Validate Field Value
.val() will give you an input element's value.
if ($("#element").val() == "") alert ("Empty!");
0 comments:
Post a Comment