Click here to Skip to main content
14,332,612 members

Web Development

 
GeneralRe: HTML Code Has Been Changed to Compressed Mode Pin
Nathan Minier10-Jul-18 7:17
professionalNathan Minier10-Jul-18 7:17 
QuestionLimit lines in bootstrap card-text component Pin
Urgen Dorjee6-Jul-18 1:04
memberUrgen Dorjee6-Jul-18 1:04 
Questionobject vs img Pin
V.4-Jul-18 20:37
professionalV.4-Jul-18 20:37 
AnswerRe: object vs img Pin
Richard Deeming5-Jul-18 1:50
mveRichard Deeming5-Jul-18 1:50 
GeneralRe: object vs img Pin
V.5-Jul-18 18:50
professionalV.5-Jul-18 18:50 
Questionstudent information Pin
Raja Jee2-Jul-18 18:31
memberRaja Jee2-Jul-18 18:31 
AnswerRe: student information Pin
Richard MacCutchan2-Jul-18 21:11
protectorRichard MacCutchan2-Jul-18 21:11 
QuestionCode Stopped Working When Controller Method Is Invoked Using AJAX Instead Of Formaction Pin
MadDashCoder24-Jun-18 1:23
memberMadDashCoder24-Jun-18 1:23 
When a user clicks on the delete button to delete a selected jqgrid row, the formaction attribute is triggered and calls my controller method, which then returns a view.

Then in this view, depending on the value of a certain viewbag, an alert will display the message "Successfully deleted" and then the jqGrid is reloaded. Below is my form code inside my MVC view:
 @using (Html.BeginForm("DeleteCustomer", "Forms", FormMethod.Post, new { enctype = "multipart/form-data", name = "Submitclaims" }))
{
<button class="btn" id="Delete" type="submit" formaction="DeleteRow" formmethod="post" name="command" value="Delete">Delete</button>
}

Everything worked fine but I would like to use a confirm modal to make user confirm his/her intention.

Since the controller method takes no parameter I thought I could just put a part of the Razor code above the modal script and the rest inside the Success section of the AJAX code inside of the modal code as seen below.
@{var message = ViewBag.Message;}
$("#DeleteDialog").dialog({
height: 280,
modal: true,
autoOpen: false,
  buttons: {
    'Confirm': function () {
        $.ajax({
            type: "POST",
            cache: false,
            url: "/Forms/MyMethod",
            success: function (data) {                                    
              @if (message == "Deleted"){
                ViewBag.Message = null;
                ViewBag.Status = null;
                <text>
                 alert("Successfully deleted!");                                            
                 jQuery("#jQGrid").clearGridData(true).trigger("reloadGrid");
                 jQuery('#jqGrid').trigger( 'reloadGrid' );
                 $('#files').empty();
                </text>
              }
            }            
         });
      $(this).dialog('close');
    },
    'Cancel': function () {
        $(this).dialog('close');
     }
  }
 });

I ran the debug and stepped through the code, I can see that the controller method worked fine but the Javascript inside of the AJAX Success section is not working. The Alert is not executing and the jqGrid is not reloading.

I also took the Javascript from the AJAX Success section and put it right after the AJAX script block but that didn't work either. Please help me fix this issue.

modified 24-Jun-18 9:03am.

AnswerRe: Code Stopped Working When Controller Method Is Invoked Using AJAX Instead Of Formaction Pin
Richard Deeming24-Jun-18 5:04
mveRichard Deeming24-Jun-18 5:04 
QuestionMy First Web API Pin
Kevin Marois20-Jun-18 8:47
professionalKevin Marois20-Jun-18 8:47 
AnswerRe: My First Web API Pin
Richard Deeming20-Jun-18 10:53
mveRichard Deeming20-Jun-18 10:53 
GeneralRe: My First Web API Pin
Kevin Marois20-Jun-18 10:59
professionalKevin Marois20-Jun-18 10:59 
GeneralRe: My First Web API Pin
Richard Deeming21-Jun-18 12:19
mveRichard Deeming21-Jun-18 12:19 
QuestionPassing jqGrid Data To Server-Side Method Pin
MadDashCoder16-Jun-18 1:54
memberMadDashCoder16-Jun-18 1:54 
QuestionHow you do make user list Pin
Nuxyer13-Jun-18 5:38
memberNuxyer13-Jun-18 5:38 
AnswerRe: How you do make user list Pin
David Mujica14-Jun-18 3:03
memberDavid Mujica14-Jun-18 3:03 
Questionwhere to post CSS questions? Pin
piano001113-Jun-18 0:38
memberpiano001113-Jun-18 0:38 
AnswerRe: where to post CSS questions? Pin
Nuxyer13-Jun-18 5:41
memberNuxyer13-Jun-18 5:41 
QuestionGet more than 1 data entry from DB using PHP Pin
Member 1386791311-Jun-18 4:01
memberMember 1386791311-Jun-18 4:01 
AnswerRe: Get more than 1 data entry from DB using PHP Pin
Jochen Arndt11-Jun-18 22:55
mveJochen Arndt11-Jun-18 22:55 
GeneralRe: Get more than 1 data entry from DB using PHP Pin
Member 1386791312-Jun-18 2:34
memberMember 1386791312-Jun-18 2:34 
QuestionSignalR - resources Pin
0x01AA9-Jun-18 9:15
professional0x01AA9-Jun-18 9:15 
QuestionMagento 2: config url rewrite? Pin
Vicent Nguyen7-Jun-18 18:06
professionalVicent Nguyen7-Jun-18 18:06 
Questionhow to merge two powerpoint presentation slides into one ppt using php or javascript ? Pin
Member 1385293031-May-18 2:22
memberMember 1385293031-May-18 2:22 
QuestionMVC - Video chat with my screen sharing web Pin
Gunasekararan30-May-18 1:24
professionalGunasekararan30-May-18 1:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.