Results 1 to 1 of 1

Thread: Newbie question: making ajax call to a different page

  1. #1

    Default Newbie question: making ajax call to a different page

    Hi Guys,

    I have the following scenario. I have a website, let's call it www.example-a.com and another one called www.example-b.com.

    a) www.example-a.com needs to make an ajax call to www.example-b.com
    b) www.example-b.com sends a json data back to www.example-a.com

    When I do my ajax call from www.example-a.com like this:
    PHP Code:
    $.getJSON'http://www.example-b/user/list', function( data ) {
       $.
    eachdata, function( keyuser ) {
          
    console.log'user name: '+user.username );
       });
    }); 
    The response on www.example-a.com is: STATUS 200 OK.

    My method call in the controller is this one:
    PHP Code:
    @Controller
    @RequestMapping("/user")
    public class 
    UserController {

       ...

       @
    RequestMappingvalue="/list"method=RequestMethod.GET )
       public @
    ResponseBody List<User> list() {
          return 
    userService.list();
       }

       ...


    The response Headers are this one:
    Code:
    Date	                     Wed, 18 Jan 2012 08:29:25 GMT
    Content-Type	     application/json;charset=UTF-8
    Transfer-Encoding     chunked
    Connection              Keep-Alive
    
    Request Headers
    
    Host	                     www.example-b.com
    User-Agent	Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
    Accept	             application/json, text/javascript, */*; q=0.01
    Accept-Language     en-us,en;q=0.5
    Accept-Encoding      gzip, deflate
    Accept-Charset        ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Connection              keep-alive
    Origin	                     null
    But the Response is empty!

    I thought it's related to a RESTful approach. Since I've never done a RESTful implementation, I thought somebody can give me hint to do it.

    I would appreciate any comments and help.
    Last edited by TomBlank; Jan 18th, 2012 at 03:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •