PDA

View Full Version : Ajax Request



arunkumargm1987
29 Jun 2010, 4:47 AM
Hi,

I am facing a problem with making an Ajax call to the server.My code for Ajax request is

var conn = new Ext.data.Connection();
conn.request({
method: 'GET',
url: url1,
success: function(responseObject) {
alert("Success");
},
failure: function() {
Ext.Msg.alert('Status', 'Unable to show history at this time. Please try again later.');
}
});

or

Ext.Ajax.request({
url: url1,
method:'GET',
success: function(response, opts) {
obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});

I have tried both these codes,its goin as "OPTIONS" in firebug. What is the solution ??

Plz help..:-?:(:s:((

Animal
29 Jun 2010, 4:59 AM
That means you are trying cross-domain.

Read: https://developer.mozilla.org/En/HTTP_Access_Control

arunkumargm1987
29 Jun 2010, 5:10 AM
Hi,

I am facing a problem in making an Ajax.request call to the server.The codes i have used is

var conn = new Ext.data.Connection();
conn.request( {
method :'GET',
url :url1,
success : function(responseObject) {
alert("Success");
},
failure : function() {
Ext.Msg
.alert('Status',
'Unable to show history at this time. Please try again later.');
}
});

& also

Ext.Ajax.request({
url: url1,
success: function(response, opts) {
obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});

The call is made as "OPTIONS" when I checked it on firebug. So,how can this be solved ??
Plz help..:-?:s:((

Animal
29 Jun 2010, 5:15 AM
Merged your two threads.

rohangpatil
29 Jun 2010, 5:34 AM
Hi Arun,

I was also facing a similar problem.
I don't have a solution though.

Probably some ExtJs Guru's here will help us. :)

mschwartz
29 Jun 2010, 6:31 AM
Ext.Ajax.request({
url: 'echo.php',
params: { a: 'this is a', b: 'this is b' },
success: function(response) {
var result = Ext.decode(response.responseText);
console.dir(result);
}
});


echo.php:


<?php
$a = $_REQUEST['a'];
$b = $_REQUEST['b'];
json_encode(array('a' => $a, 'b' => $b, 'success' => true, 'handler' => 'echo.php'));

Animal
29 Jun 2010, 6:36 AM
Hellooooooooooooooooo?

I answered this already.

arunkumargm1987
29 Jun 2010, 6:38 AM
Hi

I just figured out that we cant make cross domain requests using the Ext.Ajax... so i moved the servlet into my local app... Thanks anyways :)

Now i am facing a new problem, so it will be in a new thread :)