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 8205371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:12:50+00:00 2026-06-07T08:12:50+00:00

This could be an easy task but I am just learning the relationship between

  • 0

This could be an easy task but I am just learning the relationship between jQuery, JSON, and Javascript. I used jQuery to to pull from my database and create a variable called res[i].showlink which is a url. Here is part of my code for the call.

   $.get("http://databasecall=json", {}, function (res) {
       $.mobile.hidePageLoadingMsg();
       if (res.length) {
           var s = "";
           for (var i = 0; i < res.length; i++) {
               s += "<li><a name=" + res[i].id + " href='" + "javascript:openGoogle()" + "'>" + res[i].showlink + "</a></li>";
           }
           $("#showList").html(s);
           $("#showList").listview("refresh")
       }, "json");

The problem is that I would like reuse the res[i].showlink database variable in a javascript function (openGoogle) outside of the code above. When I go to reuse the database variable res[i].showlink, it no longer contains my data from the database. How can I reuse the variable outside of the jQuery/JSON code above? I really appreciate any suggestions. Thank you!

  • 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-06-07T08:12:52+00:00Added an answer on June 7, 2026 at 8:12 am

    You are storing that value as the contents of the anchor tag, you can access it from there too.

    change

    javascript:openGoogle()
    

    to

    javascript:openGoogle.apply(this)
    

    and then inside of openGoogle, you can access the value with $(this).text()

    Edit
    Another option is to pass the value directly as a parameter.

    change

    javascript:openGoogle()
    

    to

    javascript:openGoogle(" + res[i].showlink + )
    

    and then modify

    function openGoogle() {
    

    to

    function openGoogle(showlink) {
    

    and access the value with

    alert(showlink);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably really easy for a pro, but could someone re-write this from it's PHP
This could be a very basic Javascript I know but I just can't get
I think this could be a very easy question for you. But I have
this is prob pretty easy but if someone could explain the easiest way to
This seems like it should be really easy but I couln't find an answer
Maybe it's easy, but I couldn't really figure this out right so far... I
This could be an amazingly dumb question, but .... I don't think a standard
Im very new to Hibernate so this will probably a easy task for you
I'm sure this is a very old question, but I could not find a
This could quite possibly be the dumbest question ever asked. Our client wants us

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.