SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery dialog error

    hello
    i am getting a syntax error in my code after the button comment. which is this )};. i have tried various ways to correct it and would be grateful if someone could point out the error. many thanks


    Code:
    // feedback form
    $(document).ready(function(){
        function feedbacknew() {
    
        // jquery-ui confirm dialog box
        $("#form").dialog({
            autoOpen: false,
            resizable: false,
            modal: true,
            title: 'Submit a feedback request',
            width: 440,
            height: 470
    
            /*buttons: {
                'Remove': function () { // remove what you want to remove
                    // do something here
                    alert("this is a test alert!");
                    $(this).dialog('close');
                    $("#flex1").flexReload();
                },
                Cancel: function () {
                    $(this).dialog('close');
                }
            }*/
        });
        });
    
    
        $('#submit').click(function () {
            var name = $('.uname').val();
            var data = 'uname=' + name;
            $.ajax({
                type: "POST",
                url: "feedback.php",
                data: data,
                success: function (data) {
                    $('#message').html(data);
                    $("#flex1").flexReload();
                },
                error:function (xhr, ajaxOptions, thrownError){
                        alert(xhr.status);
                        alert(thrownError);
                    }
            });
            return false;
        });
    
        $("#form").dialog('open');
    
    }

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Last line should be });
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi. still. getting syntax error. firebug reports it as:

    Code:
    /*buttons: {
                'Remove': function () { // remove what you want to remove
                    // do something here
                    alert("this is a test alert!");
                    $(this).dialog('close');
                    $("#flex1").flexReload();
                },
                Cancel: function () {
                    $(this).dialog('close');
                }
            }*/
        });
        }); <- ERROR
    thanks

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    That }); there should be just }
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    scallio. now i get feedback new is undefined. thanks

  6. #6
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    // feedback form
    $(document).ready(function(){
        function feedbacknew() {
     
            // jquery-ui confirm dialog box
            $("#form").dialog({
                autoOpen: false,
                resizable: false,
                modal: true,
                title: 'Submit a feedback request',
                width: 440,
                height: 470
     
                /*buttons: {
                    'Remove': function () { // remove what you want to remove
                        // do something here
                        alert("this is a test alert!");
                        $(this).dialog('close');
                        $("#flex1").flexReload();
                    },
                    Cancel: function () {
                        $(this).dialog('close');
                    }
                }*/
            });
        }
     
     
        $('#submit').click(function () {
            var name = $('.uname').val();
            var data = 'uname=' + name;
            $.ajax({
                type: "POST",
                url: "feedback.php",
                data: data,
                success: function (data) {
                    $('#message').html(data);
                    $("#flex1").flexReload();
                },
                error:function (xhr, ajaxOptions, thrownError){
                        alert(xhr.status);
                        alert(thrownError);
                    }
            });
            return false;
        });
     
        $("#form").dialog('open');
     
    });


    I think i just made teh suggested changes but justlints just fine.

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    baileylo. tried your code. still errors with 'feedbacknew is not defined'. thanks

  8. #8
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How are you calling feedback new? And where are you calling it from?

  9. #9
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am calling from a onpress:feedbacknew call in flexigrid. because of the problems i was having with the original code which actually opened the dialog with the form, i was advised to include document ready function. thanks

  10. #10
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After: $(document).ready(function(){

    Add a debug statement, something to teh extent of alert("THe function should be available now");

    If you click the flexigrid before that alert popups the reason you have the issue is because the javascript is never loaded. If the alert box pops up then i'd need to see your call to the function.

    If the alert never pops up make sure you're including the javascript file.

  11. #11
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the alert dosen't popup. no error just white screen. my original code below is working of sorts loads, displays the form and prints the callback in the div. the problem i have with it, is that on the first press to open the function feedbacknew, it is fine and works. if i then close it and reopen it, the message is still there and in firebug it makes 2 calls to feedback.php. it increase the call to feedback.php each time i open it. i have so far got up to 9 and stopped. somebody suggested that i may need to use a document ready function. thanks


    Code:
    // feedback form
        function feedbacknew() {
        
            // jquery-ui confirm dialog box 
            $("#form").dialog({
                autoOpen: false,
                resizable: false,
                modal: false,
                title: 'Submit a feedback request',
                width: 440,
                height: 470
        		
                /*buttons: {
                    'Remove': function () { // remove what you want to remove 
                        // do something here 
                        alert("this is a test alert!");
                        $(this).dialog('close');
                        $("#flex1").flexReload();
                    },
                    Cancel: function () {
                        $(this).dialog('close');
                    }
                }*/
            });
        
            $('#submit').click(function () {
                var name = $('.uname').val();
                var data = 'uname=' + name;
                $.ajax({
                    type: "POST",
                    url: "feedback.php",
                    data: data,
                    success: function (data) {
                        $('#message').html(data);
        				$("#flex1").flexReload();
                    },
        			error:function (xhr, ajaxOptions, thrownError){
                            alert(xhr.status);
                            alert(thrownError);
                        } 
                });
                return false;
            });
        
            $("#form").dialog('open');
        }

  12. #12
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the alert doesn't pop up you got some issues somewhere.

  13. #13
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi baileylo. somebody suggested that in the latest code i posted, i should use .remove() instead of close. how would i code that into my latest example? many thanks

  14. #14
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got bigger issues if the Alert isn't firing...there is not reason for the alert not to be shoot as soon as the page is loaded.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •