PDA

View Full Version : Cross Domain send Form



goeast
27 Aug 2010, 1:24 AM
Hello together.

I'm working on a Webappproject with a webservice. Now, i'm workin currently on the loginfunction. The Webservice (on an oder domain) checking the form that is generated and sent by Extjs. The Result of the Webservice is JSON or XML. Now, when i send the form, i became a communication error, but the URL is correct. I can call the Webservice with the browser and became a correct request. Can anyone help me? I lost 2 days with this problem :-(

Thanks for your help

Javascript:



/*

Beinhaltet Grundfunktionen:

- Loginpruefung
- Login
- Logout

Webservice dazu: wct_base.cfc

*/

/* Login */

Ext.onReady(function(){
Ext.QuickTips.init();
var login = new Ext.FormPanel({
labelWidth:80,
frame:true,
title:'Please Login',
defaultType:'textfield',
monitorValid:true,
items:[{
fieldLabel:'Username',
name:'loginUsername',
allowBlank:false
},{
fieldLabel:'Password',
name:'loginPassword',
inputType:'password',
allowBlank:false
}],

buttons:[{
text:'Login',
formBind: true,

handler:function(){
login.getForm().submit({
method:'POST',
url:'http://myotherurl/wct_base.cfc?method=loginUser',
waitTitle:'Connecting',
waitMsg:'Sending data...',


success:function(){
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
if (btn == 'ok'){
var redirect = 'test.asp';
window.location = redirect;
}
});
},
failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors.reason);
}
else if (action.failureType == "connect") {
if (action.response.statusText) {
Ext.MessageBox.alert('fs.actionfailed error', 'Form send failed with error: ' + action.response.statusText);
}
else {
Ext.MessageBox.alert('fs.actionfailed error', 'Form send failed. Could not connect to server.');
}
} else {
if (action.response.responseText != '') {
var result = Ext.decode(action.response.responseText);
if(result && result.msg) {
Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed with error: ' + action.result.msg);
} else {
Ext.MessageBox.alert('fs.actionfailed error', 'Form load failed with unknown error (possibly missing the "success" field in the json). Action type='+action.type+', failure type='+action.failureType);
}
} else {
Ext.MessageBox.alert('fs.actionfailed error', 'Form load returned an empty string instead of json');
}
}
login.getForm().reset();
}
});
}
}]
});
var win = new Ext.Window({
layout:'fit',
width:300,
height:150,
closable: false,
resizable: false,
plain: true,
border: false,
items: [login]
});
win.show();
});
Webservice


<!---
Beinhaltet Grundfunktionen

- Logincheck
- Login
- Logout

Dazugehoeriges Javascript: wct_base.js
--->

<cfcomponent displayname="xx" bindingname="xx" namespace="xx" output="Yes">

<cfset application.dsn = "wicaretacs">

<!--- Logincheck: Prueft ob Benutzer online ist --->
<cffunction name="loginCheck" access="remote"returntype="string">
<cfreturn true>
</cffunction>

<!--- loginUser: Loggt den Benutzer ein --->
<cffunction name="loginUser" access="remote" returnformat="JSON" output="Yes" returntype="any">
<cfif isDefined("form.loginUsername") AND isDefined("FORM.loginPassword")>
<cfif form.loginUsername eq "f">
<cfset result = "{success: true}">
<cfelse>
<cfset result="{success: false, errors: { reason: 'Login failed. Try again.dd' }}">
</cfif>
<cfelse>
<cfset result="{success: false, errors: { reason: 'Login failed. Try again.dd' }}">
</cfif>
<cfoutput>#result#</cfoutput>
</cffunction>

<!--- logoutUser: Logg den Benutzer aus --->
<cffunction name="logoutUser" access="remote" returnformat="JSON" returntype="string">
<cfreturn true>
</cffunction>
</cfcomponent>