Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
api submit: replace $.post with $.ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Sep 22, 2012
1 parent 592d012 commit 1de6d92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/js/bootstrap-editable.js
Expand Up @@ -464,8 +464,12 @@
if(config.data) {
$.extend(values, config.data);
}
$.post(config.url, values, 'json')
.success(function(response) {
$.ajax({
type: 'POST',
url: config.url,
data: values,
dataType: 'json'
}).success(function(response) {
if(typeof response === 'object' && response.id) {
$elems.editable('option', 'pk', response.id);
$elems.editable('markAsSaved');
Expand All @@ -475,8 +479,7 @@
} else { //server-side validation error
config.error.apply($elems, arguments);
}
})
.error(function(){ //ajax error
}).error(function(){ //ajax error
config.error.apply($elems, arguments);
});
} else { //client-side validation error
Expand Down
1 change: 0 additions & 1 deletion test/api.js
Expand Up @@ -234,7 +234,6 @@ $(function () {
$(fx).find('.new').editable('submit', {
url: 'new.php',
error: function(data) {
console.log(data);
ok(data.errors, 'errors defined');
equal(data.errors.text, 'invalid', 'client validation error ok');
}
Expand Down

0 comments on commit 1de6d92

Please sign in to comment.