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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:35:26+00:00 2026-05-22T01:35:26+00:00

I am having a really hard time trying to get this to work. All

  • 0

I am having a really hard time trying to get this to work. All I require is to console log the object that is returned. I see nothing at all in the log although the script tag is getting injected into the head.

JSON:

jsonFeed({
    "results":{
        "loggedin": "No",
        "username": "",
        "company": ""
    }
});

JS:

function jsonFeed() {

}

window.addEvent('domready', function() {

    new Request.JSONP({
        url: <correcturl>,
        onComplete: function(data){
            console.log(data); // Nothing returned

        }
    }).send();

});

Any help is greatly appreciated.

UPDATE

I have removed the jsonFeed function at the top and changed the existing code to:

new Request.JSONP({
    log: true,
    url: loginstatus,
    callbackKey: 'jsonFeed',
    onComplete: function(data){
        console.log(data); // Nothing returned

    }
}).send();

In the log I get:

JSONP retrieving script with url:http://thedomain/LoggedStatus.aspx?jsonFeed=Request.JSONP.request_map.request_0
jsonFeed is not defined

In the this gets injected:

<script type="text/javascript" async="true" src="http://thedomain/LoggedStatus.aspx?jsonFeed=Request.JSONP.request_map.request_0"> 

-- if I expand this I see the JSON --


</script>

so a) I’m getting the jsonFeed not defined error and b) the onSuccess isn’t firing 🙁

I really do appreciate all your help guys. And I am sorry if I am missing the point 🙁

UPDATE

added:

this.jsonFeed = function(data) {
    console.log(data);
};

.. and it works. Thank you @Dimitar

I still don’t quite understand it but now it works it helps when working it out.

  • 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-22T01:35:27+00:00Added an answer on May 22, 2026 at 1:35 am

    it does not work because your callback function name ignores the one that Request.JSONP sends and returns jsonFeed instead.

    http://mootools.net/docs/more/Request/Request.JSONP

    callbackKey (string: defaults to callback) the key in the url that the server uses to wrap the JSON results. So, for example, if you used callbackKey: ‘callback’ then the server is expecting something like http://…./?q=search+term&callback=myFunction; This must be defined correctly.

    here’s an example class i wrote that gets stuff off of flickr – who use a custom callback key – it’s fine. http://fragged.org/mootools-flickr-api-class-via-request-jsonp_1042.html (p.s. jsfiddle may be slow atm, friday 13th thing!)

    the other thing is, if the remote end CONTINUES not to work with you and refuses to send data in the correctly wrapped format, eg:

    Request.JSONP.request_map.request_0({data})

    then you need to actually make sure that

    this.jsonFeed = function(data) {
        console.log(data);
    };
    

    where this is the global object (eg, window) – you cannot scope this, so careful where the function is defined.

    if doing the latter, jsonFeed will then take the role of a callback oncomplete function.

    another way is to do this, which will map the native callback function defined by the class and export it to the one your remote host likes:

    onRequest: function() {
        var lastCallback;
        Object.each(Request.JSONP.request_map, function(el) {
            lastCallback = el;
        });
        window.jsonFlickrApi = lastCallback;
    },
    onComplete: function(data) {
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a really hard time understanding delegates and object inheritance (if I may
this sounds really simple and stupid..but I'm having a hard time removing the content
I'm really having a hard time trying to figure out what's going on here.
I'm having a really hard time when trying to cancel requests in an NSOperationQueue.
I am new to iPhone programming and am having a really hard time trying
I am having a really hard time hiding console messages from my shells (ksh)
I am having a really hard time attempting to debug LINQ to SQL and
I am having a really hard time reconciling IoC, interfaces, and events. Let's see
I just start playing with GWT I'm having a really hard time to make
I'm using Microsoft Open XML SDK 2 and I'm having a really hard time

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.