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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:47:32+00:00 2026-06-06T00:47:32+00:00

I’m calling up with a $.getJSON in my custom function getSearch(). I’d like to

  • 0

I’m calling up with a $.getJSON in my custom function getSearch(). I’d like to return data straight into the container from where I’m calling. (Much easier than to .html() from the custom function. It’s on a cloned object.) I’m trying two ways: 1. To return the data directly into the callling function, since I already “know where I am.” 2. To pass a var for the correct container to the function, so it can be put into the right place from there. I guess I prefer the first alternative, but right now I can’t get either to work.

These are my functions – one fires on pressing enter in a search box, the other is the custom function that calls up twitter with $.getJSON(). Relevant lines marked with ##.

    // RUN SEARCH: when pressing enter key in search box
    $('.search_box_in_menu').keypress(function(e) {
        var keycode = (e.keyCode ? e.keyCode : e.which);
        if(keycode == '13') {                   // remember to add all the enter/return buttons
                console.log(".search_box_in_menu - enter-key pressed.");
                console.log($(this).val());
            var where = $(this).parent().parent().parent();
            var there = $(this).next('.results').attr('class');
            console.log("where:");
            console.log($(this));
            console.log($(this).parent().parent().parent());
            console.log($(this).next('.results').attr('class'));
            console.log(where);
            console.log("there:");
            console.log(there);
    ##      $(this).closest('.results').getSearch($(this).val(), where);    //calling twitter
                console.log("$(this).val() at enter-press: " + $(this).val());

            $(this).closest('.dropdown').trigger('click'); //close dropdown box
            $('.search_box_in_menu').tooltip('hide'); //hiding tooltip on searchbox when pressing enter
        }
    });



}); //$(document).ready 



// function for getting tweets from Twitter
$.fn.getSearch = function(searchword, where) { 
    var qterm = searchword;
    var preUrl = "http://search.twitter.com/search.json?q=";
    var postUrl = "&rpp=50&include_entities=true&show_user=true&callback=?";
    var twUrl =  preUrl + qterm + postUrl; 
    console.log(preUrl + ", " + qterm + ", " + postUrl);

    if (qterm !== '') {
        $.getJSON(twUrl, 
            function(data) { 
                console.log('sending to search_back.php.');
                console.log("data before send: " + data);
                $.post("search_back.php", {json_data: data}, function(data) { 
                        console.log("returned at: ");
                        console.log($(this));
                        console.log(where);
            ##      $(".results").html(data); // # this is the current way, but will apply to all cloned objects.
            ##      //return data; // # this is the preferred way
                });

            });
    };
};

Anybody know how to solve this in a handsome way? I don’t really want to assign an ID to the .results either, as it seems there must be a much more elegant way to solve this!

This is the FireBug console log: the .results I’m after is the next after [div id=”menu200″].

document.ready -
[div#menu200.dropdown]
.dropdown - click.
.search_box_in_menu - click.
.search_box_in_menu - value removed.
.search_box_in_menu - enter-key pressed.
twitter
where:
[input.search_box_in_menu Search...]
[div#menu200.dropdown]
undefined
[div#menu200.dropdown]
there:
undefined
http://search.twitter.com/search.json?q=, twitter, &rpp=50&include_entities=true&show_user=true&callback=?
$(this).val() at enter-press: twitter
[div#menu200.dropdown]
.search_box_in_menu - dirty searchbox.
.dropdown - click.
sending to search_back.php.
data before send: [object Object]
POST http://wikindoit.org/twitterstars/search_back.php
200 OK
927ms   
returned at:
[Object { url="search_back.php", isLocal=false, global=true, more...}]
[div#menu200.dropdown]
  • 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-06T00:47:35+00:00Added an answer on June 6, 2026 at 12:47 am

    add a 3rd parameter to getSearch:

    $.fn.getSearch = function(searchword, where, callback) {
    

    and at the end of the success callback of getScript you would call callback and pass to it whatever you want.

    //$(".results").html(data);
    callback(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.