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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:29:20+00:00 2026-05-16T14:29:20+00:00

I post JSON request to remote service. Everything is OK, service works fine and

  • 0

I post JSON request to remote service. Everything is OK, service works fine and it response to me. But I have no data returned from remote service. How to get data from remote json service by JQuery via .post? Why this example returns the data — “null’:

<SCRIPT> 
$(function() {
    $('#zzz').click(function() {
        $('#lak').html('wait...');
        $.post(
  'http://127.0.0.1:3000/test',
  "{\"ipaddr\":\"192.168.132.58\"}",
  function(data) { alert(data); },
  "json"
        )
    });
});
</SCRIPT>

But the TCP sniffer shows me that service returns some data:

HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Type: application/json
X-Powered-By: Mojolicious (Perl)
Date: Thu, 02 Sep 2010 06:17:10 GMT
Content-Length: 37
Server: Mojolicious (Perl)

{"status":"OK","result":"successful"}

Solved:

<SCRIPT> 
$(function() {
    $('#clickme').click(function() {
 $.getJSON('http://domain.tld/test/?foo=bar&callback=?',
 function(jsonp) {
  $('#jsonp-example').html(jsonp.result);
 });
    });
});
</SCRIPT>

<div id="jsonp-example"><a id="clickme" href="javascript:void()">Click me</a></div>

And example of Mojolicious JSONP service:

# /test/?foo=bar&callback=smth
get '/test' => sub { 
 my $self = shift;

 my $foo  = $self->param('foo') || '';
 my $callback = $self->param('callback') || 'jsonp';
...
 my $json = $self->render(
  json => {
   'status' => 'OK',
   'result' => 'successful'
  }, 
  partial => 1);

 $self->render(data => "$callback($json)", format => 'js');
} => 'test';
  • 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-16T14:29:20+00:00Added an answer on May 16, 2026 at 2:29 pm

    You’e running into the same-origin policy which prevents (among other things) an XmlHttpRequest from getting data from a remote domain. Your POST will be successful, but the browser won’t allow you to get the response back.

    Since you’re going to a remote domain, your best shot is to support JSONP, it works in a different way, you can’t POST so it’ll get a GET, but it will allow you to get data back. JSONP uses an entirely different method of getting the data, basically defining your callback as a name function then creating a <script> tag in the page. The remote server responds with namedFunction({ ...JSON data }), which your page runs…without needing an XmlHttpRequest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.