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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:00:06+00:00 2026-05-26T16:00:06+00:00

I have a web service with this form: http://<remote_domain_ip>/api/v1/search/?query=the_query Which results a JSON document

  • 0

I have a web service with this form:

http://<remote_domain_ip>/api/v1/search/?query=the_query

Which results a JSON document in response.

How do I create/compose a JQuery JSON/ajax call so I can get the response back?

Reponse is in form:

{
"status_code":200,
"status_txt":"OK",
"field1":"abc",
"field2":"some_text"
}
  • 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-26T16:00:07+00:00Added an answer on May 26, 2026 at 4:00 pm

    It depends. If you are say on domain a.com and your web service is also located at the same place, then you can simply do it this way:

    $.ajax('path-to-your-service/WebMethodName', data, function(r){
        // Success callback, you have your answer in r.d object
    }, function(e){
        // Error callback
    });
    

    However, if you are on say b.com and the web service is located on a.com, then you are limited by a concept called Same-Domain Policy. In other words, you can’t use AJAX calls (or XMLHttpRequest) to fetch data from that web service, unless you follow certain rules. One is to use Access-Control-Allow-Origin HTTP Header field, which has some cross-browser issues. Another way could be to use JSONP, which requires the server to support it.

    To use JSONP, you should use jQuery’s $.getJSON() method, and provide a callback query string key alongside your parameters sent via HTTP GET.

    $.getJSON('path-to-your-service?x=some&y=thing?callback?', function(r){
        // Success callback. Your JSON object would be the r parameter
    });
    

    I recommend that you use JSONP, if you are the creator of the web service, and if you use .NET framework, I also recommend that you simply use a Generic Handler instead of a web service, since we had many problems configuring web service. However, in your server code, you should check the incoming GET request for a query string key called callback, and if it exists, you should wrap your returning JSON inside a function this way:

    callback({
       a: a1,
       b: b1,
       c: c1
    });
    

    Understanding JSONP (the concept and the way it occurs) is very crucial. Without a deep understanding, your future maintenance would be a huge burden. I suggest reading this question.

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

Sidebar

Related Questions

I have a SpringMVC web service for uploading files which looks like this: @RequestMapping(value=/upload.json,
I have this web service : using System.Web.Services; namespace Contracts { [WebService(Namespace = http://tempuri.org/)]
I have an echo web service running on lets say http://localhost:8080/axis2/services/Service1 . This service
I have a web service that queries data from this json file, but I
I have a web service to which I send a xml request (application/x-www-form-urlencoded encoded)
I have a web service in the form `http://....../methodName It returns a jsonp result
I have a REST web service that currently exposes this URL: http://server/data/media where users
I have developed a small C# form application which calls a web service. Everything
I have a web service implemented in WCF. This service is only going to
I have created an web service I need to publish this service. I need

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.