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

  • Home
  • SEARCH
  • 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 7051423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:15:42+00:00 2026-05-28T03:15:42+00:00

I am a newbie on web development, just started learning ajax request and dynamic

  • 0

I am a newbie on web development, just started learning ajax request and dynamic content creation.

I have no problem in loading and parsing data. After loading data, Dynamically I create multiple rows represent each element of array (response of ajax request):

 for(var i=0; i< dicts.length; i++){
     var dict = dicts[i];
     div_content += "<div id='row' " + 
                         "onclick='callJs("+ dict.get('itemId') +");'>" + 
                        <b>" + dict.get('name').toUpperCase()+ "</b>&nbsp;"+ 
                        dict.get('itemId') + "&nbsp;" +
                        dict.get('active_deals') + " DEAL <br/>" + 
                        dict.get('popularity') + ". POPULAR BRAND <br/>" + 
                        "<img src='resources/list_break.png' /><br/>" +
                        "</div>"; 
  }

dict.get(‘itemId’) is Long(26 digits) as a string. When I click a row, ‘callJs’ function fires, but a strange issue happens. My Long as a string becomes a Long, for example :

row id -->  85511111031103236921544356 ,   
in function I see, row id -->   8551111103110325e+25   

my string turns into a Long, I cannot understand. I also checked that my parser returns right value. I think dynamically created row’s click function converts string to long.

function callJs(itemId) {
     alert(itemId); // prints  8551111103110325e+25
     alert(itemId.toString()); // prints 8551111103110325e+25
}

As you see, in iterator loop, I print itemId of each row, prints right value (85511111031103236921544356):

enter image description here

I could not find any solution anywhere. I wanna pass the id of each row to my function.

Any solution make me so glad..

Thanks in advance..

  • 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-28T03:15:43+00:00Added an answer on May 28, 2026 at 3:15 am

    In this line:

    "onclick='callJs("+ dict.get('itemId') +");'>"  +
    

    The Html generated will look like this:

    "onclick='callJs(11111112222222);'>"
    

    So, callJs is being called with an integer argument.

    You need to change the line to be something like this like this:

    "onclick='callJs(\""+ dict.get('itemId') +"\");'>" + 
    

    Which will result in this HTML being generated:

    "onclick='callJs("11111112222222");'>"
    

    Here, callJs is being called with a string argument.

    In general, when generating dynamic HTML, you have to ensure that the HTML formed is correct. Mostly this means checking that you have ' and " characters around data that should be interpreted as a string, and ensuring that these characters do not end up in the wrong place (For instance, in the middle of the string).

    There are tools to help you with this. For instance, see firebug for firefox, or the various inbuilt tools in the other browsers.

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

Sidebar

Related Questions

i am a newbie on web development, so i have some problems first of
I am a newbie to Java Web Application development. So far all I have
I have to tell you guys first that I'm a newbie of web development
As a newbie in the world of web development, I have a handful of
Pardon the dumb newbie question here; web programming isn't my forte... (blush) I have
Well,I am learning the web development and currently working on PHP and mySQL ,I
I'm a relative newbie to web development. I know my HTML and CSS, and
I am a newbie in web-development and am trying to use Jmeter for doing
I am newbie in SharePoint 2010 but have experience in ASP.NET (C#) development. I
I'm making my way into web development and have seen the word postback thrown

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.