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

The Archive Base Latest Questions

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

here i am learning jsonp and i have a little problems with a simple

  • 0

here i am learning jsonp and i have a little problems with a simple code ,
what i am trying to do is a simple jsonp callback but it seems to not working

here is the code:

[index.php]

<html>
    <head>
        <script type="text/javascript" id="myJSONPCall" src="http://mySubDomain.comoj.com/jsoncall.php?jsonCallback=myCallback"></script>
        <script type="text/javascript">
            function myCallback(obj) {
                alert(obj.text);
            }
        </script>
    </head>

    <body>
    </body>
</html>

[jsoncall.php]

<?php   
    $myObject = array(
        "text" => "Hello, I am data from the remote server.",
        "created_at" => "Thu May 07 21:36:12 +0000 2009"
    );

    $myJSONObject  = json_encode($myObject);

    $myJSONCallback = filter_var($_REQUEST['jsonCallback'], FILTER_SANITIZE_STRING);

    print "$myJSONCallback($myJSONObject)"
?>

right away , nothing happen.
what exactly goes wrong here?

  • 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-26T01:15:20+00:00Added an answer on May 26, 2026 at 1:15 am

    You need to define your function before calling the url that loads the response
    just switch the order your your scripts.

    <html>
        <head>
             <script type="text/javascript">
                function myCallback(obj) {
                    alert(obj.text);
                }
            </script>
            <script type="text/javascript" id="myJSONPCall" src="http://mySubDomain.comoj.com/jsoncall.php?jsonCallback=myCallback"></script>
    
        </head>
    
        <body>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning by reading this tutorial: Link Here's the code: <?php require_once 'Zend/Loader.php'; class
Here's the deal: I'm trying, as a learning experience, to convert a C program
I'm learning this right now so the questions might be a little juvenile. Here's
I have started learning MVC2. I developed a simple customer search screen with Jquery
I have been lurking and learning in here for a while. Now i have
I'm still learning here and have a question about child collections. I have an
I may be the minority here, but it seems through my entire academic/professional career
I'm learning the basics of programming here (C#) but I think this question is
Ok still learning here. If I have one form calling another form like below
From couple of days, I have started working/learning the backbone.js . I have read

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.