Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6650237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:52:10+00:00 2026-05-26T00:52:10+00:00

I have the following Javascript code: $(‘td:eq(2)’, nRow).html(‘<a class=critical href=# OnClick=toAjax(\”+aData[1]+’\’, \”+aData[2]+’\’);>’+aData[3]+'</a>’); I’m getting

  • 0

I have the following Javascript code:

$('td:eq(2)', nRow).html('<a class="critical" href="#" OnClick="toAjax(\''+aData[1]+'\', \''+aData[2]+'\');">'+aData[3]+'</a>');

I’m getting in Firebug the following error message

toAjax is not defined

My function:

    $(document).ready(function() {

        oTable = $('.statisticsTable').dataTable({

                "bJQueryUI" : true,

                "iDisplayLength" :50,

                "sAjaxSource": 'arrays.txt',

                "aoColumns"   : [{ "bSearchable": true, "bVisible": false },null, null, null, null, null,null,null,null,null,null],

                "fnRowCallback" : function(nRow, aData, iDisplayIndex) {

                    if (aData[3] == "1") {
                        $('td:eq(2)', nRow).html('<a class="critical" href="#" OnClick="toAjax(\''+aData[1]+'\', \''+aData[2]+'\');">'+aData[3]+'</a>');

                        } 

                    else if

                    (aData[4] == 123) {
                        $('td:eq(3)', nRow).html( '<a class="critical" href="serverID='+aData[0]+'&db='+aData[1]+'&task=Workload'+'">'+aData[2]+'<span class="highcharts"></span></a>' ).attr("class","kritikal");



                    } 

                    else if

                    (aData[3] >1) {
                        $('td:eq(3)', nRow).html( '<a id="ajax_call" class="critical" href="#">'+aData[3]+'<span class="highcharts"></span></a>' );

                        } 

                    return nRow;
                },


            } );


        function toAjax( server, db )
        {
            $.ajax({
                type: "POST",
                url: "someurl.php",
                data: "server=" + server + "&db=" + db,
                success: function(msg){
                    alert( "Data Saved: " + msg );
                }
            });
        }


    }); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:52:10+00:00Added an answer on May 26, 2026 at 12:52 am

    I can get this to work (a simplified example):

    <table>
        <tbody>
            <tr>
                <td>1</td>
                <td>1</td>
                <td>1</td>
            </tr>
        </tbody>
    </table>
    
    $(document).ready(function(){
        var aData = [1,2,3,4];
        $('td:eq(2)')
            .html('<a class="critical" href="#">'+aData[3]+'</a>')
            .children('a.critical')
                .click(function(){
                    toAjax(aData[1],aData[2]);
                });
    });
    
    function toAjax( server, db )
    {
        console.log(server, db);
        return false;
    }
    

    http://jsfiddle.net/Va39r/2/

    Note how I add the click handler AFTER I add the html. This makes adding the handler much cleaner than with an inline text.

    EDIT – After seeing your edit, the below is the reason your toAjax() function is ‘not defined’.

    Also, I would check to make sure the toAjax() is declared and not within a function scope (for instance, you don’t have it in a $(document).ready() block).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have the following code in JavaScript and jQuery: $(<li />) .html('Some HTML') I
I have the following javascript code which changes the class (of the <ins> tag)
I have the following HTML code: <div id=scroll> <div class=foo>foo1</div> <div class=foo>foo2</div> .... <div
I have the following HTML w/Javascript code (note: this only works in Internet Explorer):
I have the following JavaScript code to pop up a window in Internet Explorer.
I have the following javascript code, which loads without error, however the update function
I have the following JavaScript code: Link In which the function makewindows does not
I have the following JavaScript code: oCoord = {x: null, y: null}; var aStack
I have the following Javascript code. When the page is loaded it is scrolled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.