javascript - Why my request returns back only JSON, my page lose -
javascript - Why my request returns back only JSON, my page lose -
when edit product, client side validation works. want check server side validation. used next code other objects. worked. utilize same code in product edit page. not work:
jquery(document).ready(function () { ... if (jquery('#producteditform').validationengine('validate')) { jquery.post('/product/edit', { productid: jquery('#productid').val(), price: jquery('#price').val(), name: jquery('#name').val(), formname: 'product_edit_form', formtype: 'producteditf' }, function (result) { if (!result.success) { alert(result.error); } }); homecoming false; } else { homecoming false; } ... });
in productcontroller:
[httppost] public actionresult edit(product model) { var result = //my edit operation if (result.issuccessfull) { homecoming json(new { error = "", success = true }, jsonrequestbehavior.allowget); } else { homecoming json(new { error = "error occured!", success = false }, jsonrequestbehavior.allowget); } }
when result not successfull, action returns line:
why page lose?
i think want this:
jquery.post('/product/edit', { productid: jquery('#productid').val(), price: jquery('#price').val(), name: jquery('#name').val(), formname: 'product_edit_form', formtype: 'producteditf', success: function(){ alert('success'); }, error: function(){ alert('failure'); } });
javascript jquery asp.net-mvc json jquery-validation-engine
Comments
Post a Comment