JQuery timer plugin on ASP.NET MVC Page button click

Posted by Rita on Stack Overflow See other posts from Stack Overflow or by Rita
Published on 2010-03-15T23:21:34Z Indexed on 2010/03/15 23:29 UTC
Read the original article Hit count: 280

Filed under:


I have an ASP.NET MVC Page with a button called "Start Live Meeting".

When the User clicks on this button, it calls a controller method called "StartLiveMeeting" that returns a string.

If the controller returns empty string, then i want the Timer to call the Controller method until it returns the string. I am using jquery.timer.js plugin ( http://plugins.jquery.com/files/jquery.timers-1.2.js.txt )

On the button click, the controller method is being called. But Timer is not initiating. I have specified 5sec to call the controller method.

I appreciate your responses.

Code on ASPX Page:

//When "Start Meeting" button is clicked, if it doesn’t return empty string, Display that text and Stop Timer. Else call the Timer in every 5 sec and call the StartLiveMeeting Controller method.

$("#btnStartMeeting").click(function() {
    var lM = loadLiveMeeting();
    if (lM == "") {
        $("#btnStartMeeting").oneTime("5s", function() {
    } else {
    return false;
function loadLiveMeeting() {
    $("#divConnectToLive").load('<%= Url.Action("StartLiveMeeting") %>', {}, function(responseText, status) {
        return responseText;

<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="server">

<div id="divStartMeetingButton"><input id="btnStartMeeting" type="submit" value="Start Meeting" /> 
           <div id = "divConnectToLive">
               <div id="loading" style="visibility:hidden"> 
                    <img src="../../img/MedInfo/ajax_Connecting.gif" alt="Loading..." />

Controller Method:

    public string StartLiveMeeting()
        int intCM_Id = ((CustomerMaster)Session["CurrentUser"]).CM_Id ;
        var activeMeetingReq = (from m in miEntity.MeetingRequest
                                where m.CustomerMaster.CM_Id == intCM_Id
                                && m.Active == true
                                select m);

        if (activeMeetingReq.Count() > 0) 
            MeetingRequest meetingReq = activeMeetingReq.First();
            return "<a href='" + meetingReq.URI + "'>" + "Connect to Live Meeting</a>"; 
        } else {
            return ""; 

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-2