Skip to content

Commit 1997cf0

Browse files
committed
Fix JSON parsing.
1 parent 39fe7ee commit 1997cf0

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

validation/views/index.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@
2929
<button>Submit</button>
3030

3131
<script type="text/javascript">
32-
$(document).ready(function() {
33-
$('button').bind('click', function() {
34-
$.post('/?ts=' + new Date().getTime(), $('#f').serialize(), function(d) {
35-
var err = $('#error');
36-
37-
if (d instanceof Array) {
32+
$(document).ready(function() {
33+
$('button').bind('click', function() {
34+
$.post('/?ts=' + new Date().getTime(), $('#f').serialize(), function(d) {
35+
var err = $('#error');
36+
d = JSON.parse(d);
37+
if (d instanceof Array) {
3838

39-
err.empty();
40-
d.forEach(function(o) {
41-
err.append('<div>' + o.error + '</div>');
42-
});
43-
err.show();
44-
return;
45-
};
39+
err.empty();
40+
d.forEach(function(o) {
41+
err.append('<div>' + o.error + '</div>');
42+
});
43+
err.show();
44+
return;
45+
};
4646

47-
err.hide();
48-
alert('Form is valid.');
49-
});
50-
});
51-
});
47+
err.hide();
48+
alert('Form is valid.');
49+
});
50+
});
51+
});
5252
</script>

0 commit comments

Comments
 (0)