ajax跨域调用示例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> http://www.ogtest.com/login/login/checkpwd php代码如下: $loginId = stringHelper::searchTrim($this->getParam("loginId")); $pwd = stringHelper::searchTrim($this->getParam("pwd")); $userIdRemember = stringHelper::searchTrim($this->getParam("userIdRemember"))?TRUE:FALSE; $arrCondition = array(); $arrCondition["loginId"] = $loginId; $arrCondition["pwd"] = $pwd; //记住用户登录状态 $userRemember = $this->_request->getCookie('userRemember'); $arrCondition['userRemember'] = json_decode($userRemember,true); if ($this->getParam("chkUserIdRemember") == "on") { $arrCondition["userIdRemember"] = TRUE; } else { $arrCondition["userIdRemember"] = FALSE; } $crossdomain = stringHelper::searchTrim($this->getParam("crossdomain")); $return = $this->_facade->pbLogin($arrCondition); if($crossdomain==false){ //非跨域调用 if($return['isError']==false){ //密码和账号正确 $arrOutPut = array("result"=>'1'); }else{ //密码和账号不正确 $arrOutPut = array("result"=>'0'); } jsonHelper::outPutJson($arrOutPut); }else{ //跨域调用 if($return['isError']==false){ //密码和账号正确 $arrOutPut = array("result"=>'1'); $str = '[{"result":"1"}]'; }else{ //密码和账号不正确 $str = '[{"result":"0"}]'; } $jsonp = $_REQUEST["callback"]; $str = $jsonp . "(" .$str.")"; echo $str; exit; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |