Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Mobile Groovy
I has been issue when I call ajax from sencha to grails.
XMLHttpRequest cannot load http://localhost:8080/ExtLogin/userInfo/index/login. Origin http://localhost:9090 is not allowed by Access-Control-Allow-Origin.
Code below:
Sencha: Sencha application deploying on “http://localhost:9090/sencha/demo/Login/” using Tomcat
Grails application using Tomcat at “http://localhost:8080/ExtLogin/userInfo/index/login”. Login function at server side render JSON is below:
def login(){
def response = ['success':'true']
response.addHeader("Access-Control-Allow-Origin", "*")
response.addHeader("Cache-Control", "no-cache")
render response as JSON
}
If request from browser, I received:
Request URL: http://localhost:8080/ExtLogin/userInfo/login
Request Method: GET
Status Code: 200 OK
Request Headersview source
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: UTF-8,*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:8080
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22
Response Headers: Access-Control-Allow-Origin:*
Cache-Control:no-cache
Content-Type:application/json;charset=UTF-8
Date: Mon, 11 Mar 2013 02:33:35 GMT
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
==
And if request from sencha app, I received:
Request URL:http://localhost:8080/ExtLogin/userInfo/index/login
Request Method: OPTIONS
Status Code: 200 OK
Request Headersview: Accept: */*
Accept-Charset: UTF-8,*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Access-Control-Request-Headers:origin, x-requested-with, content-type
Access-Control-Request-Method: POST
Connection: keep-alive
Host: localhost:8080
Origin: http://localhost:9090
Referer: http://localhost:9090/sencha/demo/Login/
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22
Response Headers Allow:
GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
Content-Length: 0
Date: Mon, 11 Mar 2013 02:44:03 GMT
Server: Apache-Coyote/1.1
 
Please help me!
Posted 10-Mar-13 18:05pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 520
1 Mathew Soji 335
2 BillWoodruff 260
3 OriginalGriff 215
4 Afzaal Ahmad Zeeshan 188
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,028
3 Manas Bhardwaj 4,539
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 10 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100