javascript - How to fix this js script to send a value by method post -


i have javascript , want click ok , call detel method in controller, not working , don't know why.

i need 2 values in submit:
id , name.

also don't know url should because method doesn't change. i'm in delete right in method.

here code:

<script type="text/javascript">     $(function () {         $("#dialog-confirm").dialog({             resizable: false,             height: 140,             modal: true,             buttons: {                 "ok": function () {                     $.ajax({                         type: "post",                         url: "",                         data: { name: viewbag.productname, id: viewbag.productid },                         success: function () {                             alert("succes");                             $("#result").html('submitted successfully');                          },                         error: function () {                             alert("failure");                             $("#result").html("there error submit");                         }                     })                     $(this).dialog("close");                 },                 anuluj: function () {                     $(this).dialog("close");                 }             }         });     });   </script> 

try this

<script type="text/javascript"> $(function () {     $("#dialog-confirm").dialog({         resizable: false,         height: 140,         modal: true,         buttons: {             "ok": function () {                 $.ajax({                     type: "post",                     url: "/controllername/actionname",                     data: { name: '@viewbag.productname', id: '@viewbag.productid' },                     success: function () {                         alert("succes");                         $("#result").html('submitted successfully');                      },                     error: function () {                         alert("failure");                         $("#result").html("there error submit");                     }                 })                 $(this).dialog("close");             },             anuluj: function () {                 $(this).dialog("close");             }         }     }); }); 


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -