Javascript $state.go无法在Internet explorer中工作
我正在使用angular.js作为小应用程序。在用户填写数据并单击Javascript $state.go无法在Internet explorer中工作,javascript,jquery,angularjs,internet-explorer,state.go,Javascript,Jquery,Angularjs,Internet Explorer,State.go,我正在使用angular.js作为小应用程序。在用户填写数据并单击submit按钮后的注册页面中,从控制器调用一种方法,进行API调用,然后在下一页重定向用户。这在Chrome、Firefox和Microsoft Edge中运行良好,但在Internet Explorer中不起作用 这是我的signup.html <form name="userRegForm" ng-submit="userRegForm.$valid && registerUser()"&g
submit
按钮后的注册页面中,从控制器调用一种方法,进行API调用,然后在下一页重定向用户。这在Chrome、Firefox和Microsoft Edge中运行良好,但在Internet Explorer中不起作用
这是我的signup.html
<form name="userRegForm"
ng-submit="userRegForm.$valid && registerUser()">
<md-input-container class="md-block">
<label>Full name</label>
<input required
ng-model="user.fullName"
name="fullName"
id="fullName"
autocomplete="off"
ng-pattern="/^[a-zA-Z ]*$/">
<div ng-messages="userRegForm.fullName.$error">
<div ng-message="required">Full name is required.</div>
<div ng-message="pattern">Please enter valid name</div>
</div>
</md-input-container>
<md-input-container class="md-block">
<label>Email</label>
<input required name="emailId" ng-model="user.emailId" type="email" autocomplete="off">
<div ng-messages="userRegForm.emailId.$error">
<div ng-message="required">Email is required.</div>
<div ng-message="email">Please enter valid Email.</div>
</div>
</md-input-container>
<md-input-container class="md-block">
<label>Password</label>
<input required name="password" ng-model="user.password" type="password" autocomplete="off">
<div ng-messages="userRegForm.password.$error">
<div ng-message="required">Password is required.</div>
</div>
</md-input-container>
<section id="non-padding" style="overflow: hidden">
<div class='layout layout--middle'>
<div class="layout__item xs-mb1 sm-text-right xs-text-right col-xs-4 sm-5of12 xs-6of12 sm-push7of12 sm-mb0 padding-right-0">
<input placeholder="REGISTER" type="submit" class="button button button--primary"
value="SIGN UP">
</div>
</div>
</section>
</form>
这段代码在所有其他浏览器中都能正常工作,但不仅仅是在Internet explorer中(我有v11和Windows 10)
在这个问题上,我有很多关于谷歌的建议,但一些答案是替换ng click=“function\u name()”
直接ng click=“$state.go()”
,但这在我的情况下不起作用
谢谢IE缓存ajax请求可能会有问题。尝试使用服务器上的HTTP响应头禁用缓存,这样可以防止IE缓存Ajax调用
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires",0);
您可以尝试全局禁用,如:
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
// Answer edited to include suggestions from comments
// because previous version of code introduced browser-related errors
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
// extra
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);
未提及抛出的错误或使用的angular和router版本。提供一个演示,根据m不获取任何错误来重现问题,然后使用stateChange错误处理程序获取更多详细信息。还不清楚请求是否成功您是否有任何
控制台.log
错误?没有错误,即使在使用$stateChangeError
handler之后也没有错误。要知道我没有使用ajax calli使用了$http sendPostRequest=函数(url,payLoad,onSuccess,onError){data={'payLoad':JSON.stringify(payLoad)};$http({method:'POST',url:url,data:$.param(data),带凭据:true,头:{'Content Type':'application/x-www-form-urlencoded'}})。然后(函数successCallback(response){onSuccess(response);},函数errorCallback(err){onError(err);});};您可以尝试使用以下命令全局禁用
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
// Answer edited to include suggestions from comments
// because previous version of code introduced browser-related errors
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
// extra
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);