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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:32:32+00:00 2026-06-04T18:32:32+00:00

I dont know if this is possible because I’m pretty new to JSON and

  • 0

I dont know if this is possible because I’m pretty new to JSON and jQuery. These are my two scripts:

$.getJSON('http://shop.com/test/?format=json', function(data){
  $.each(data.textpage, function(index, text){
    $('<div></div>').html('' + text + '').appendTo('.verzendkosten');
  });
});

and

$.getJSON('http://shop.com/vraag/?format=json', function(data){
  $.each(data.textpage, function(index, text){
    $('<div></div>').html('' + text + '').appendTo('.eigenschappen');
  });
});

Is it possible to combine these two? Both scripts work but I’m curious how or if these can be combined.

  • 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-04T18:32:33+00:00Added an answer on June 4, 2026 at 6:32 pm

    Not sure what you mean by combining. I am assuming you would like to get rid of the duplcate code in both the snippets.

    Wrap this into a generic re-usable function and pass the page name and class name as parameter

    function DoSomethingGreat(page,targetClass)
    {
       $.getJSON('http://shop.com/'+page+'/?format=json', function(data){
         $.each(data.textpage, function(index, text){
           $('<div></div>').html('' + text + '').appendTo(targetClass);
         });
       });
    }
    

    and Call it like

    DoSomethingGreat('test','.verzendkosten')
    

    and

    DoSomethingGreat('vraag','.eigenschappen')
    

    wherever applicable

    EDIT : As per the comment,

    If you want to execute these when some page loads, Use the jQuery dom ready function.

    Put this in the page where you want to call it

    $(function(){
       DoSomethingGreat('vraag','.eigenschappen')
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First let me say i dont know if this is possible the way im
I dont know if this is possible: SELECT * FROM stuff WHERE barcode =
I really dont know if this is possible or not. But I am strucking
I cant find any documentation on this, I dont even know if its possible.
I know this is possible because one of my older solution files has a
I don't know whether this is really possible, but I'm trying my best. If
I don't even know if this is possible. I want to do something like:
I don't even know if this is even possible, but I thought I'd ask.
I dont know how doable this is but I'm working on a datatype for
I dont know where my error is in this mysql query $sql = INSERT

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.