I am trying to send a HTTP Post method from IE11 but it's not working. When Fiddler is open it detects a protocol violation: "Content-Length mismatch : Request header indicates X bytes, but client sent 0 bytes". It's working on Chrome, and I can't find a reason why it won't work in the IE11. I make the call using angular resource (In case it matters).
Thanks :)
Me and my friends realized what the problem is. IE Has a problem with location.reload(true) for an unknown reason. Instead we injected angular's $route and reloaded the page using the function $route.reload()
Related
I am testing AngularJS app and very new to protractor. Every time I open the browser, it gets opened and then waits for the timeout before throwing the following error on cmd.
Timed out waiting for Protractor to synchronize with the page after 50001ms
I have tried increasing the timeout limit, but always get this error.
I have also tried using all of these:
browser.ignoreSynchronization = true;
browser.driver.sleep(5000);
browser.debugger();
browser.waitForAngular();
The page loads properly and if I use Eclipse and Selenium to interact with button objects, it just works fine.
Only protractor is having Sync issues. Please Help.
Possible reasons why Protractor would time out:
Your web page doesn't implement Angular in an expected way (i.e. with an ng-app on the body tag). More often, the error you will get in this case is Angular not found on page, but a timeout isn't out of the question. Using ignoreSynchronization would fix this if it were the issue, so this one isn't you.
An HTTP request is pending or fails. Open up your dev console and check the "Network" tab when the page loads with Protractor (it may happen with Protractor and not in a manual test). If you find something failing, make sure you are issuing the request correctly. For example, if you're trying to access an HTTP endpoint through HTTPS, it's definitely possible that the request would fail and Protractor would time out.
Your page is polling $timeout or $http repeatedly. Protractor won't do anything until Angular has reached a "resting" state (all elements and data bindings are loaded and all requests have returned).
The official list of timeout reasons is here: https://github.com/angular/protractor/blob/master/docs/timeouts.md.
But if you check the Javascript console and Network requests as the page loads, you should be able to figure out what's wrong. Good luck!
I am using angular 1.2
I have configured
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode(false);
When using IE8 and IE9 I got two requests:
POST /base/action
GET /base/#!/action
So parameters from the first post are tragically lost...
The simple solution is just to send POST /base/#!/action on ie8 and 9 (so there is no redirection), but since this is partially out of our control.
I was wondering if there is a solution to send a POST for the request 2., even if some server side processing (for example to expose in JS POST data) is needed.
EDIT:
Some more details on the scenario. I am talking about the first request we get to our site. The request is done by a third party, and it must be done using POST. As a result the user should see the first page of our angular application. I am not talking about a request made with $http, and this is not a call to an API. The expected result is an HTML page. The POST request is coming from another page, using "classical" form submit method.
I finally decided to use fallback mode #! on all the borwsers, so I do not have this issue and I keep things simple.
I'm running some integration tests with Jasmine and a custom angular-mocks module (to allow real HTTP calls).
When doing a $http.delete (HTTP DELETE) on a URL, the call is successful (backend received it) but on PhantomJS's side I don't get any callback (the promise aint resolved).
I'm not having this problem with Chrome nor firefox therefore I'm suspecting PhantomJS to be buggy somehow.
Any idea if there is something I could do ?
PS: I already filed an issue on PhantomJSs GitHub.
Well actually it wasn't no callback at all. After increasing jasmine's timeout and karma's captureTimeout to 60s and waiting for 20sec I finally got my callback.
But It's kinda weird it take so much time with Phantom.
In an Angular JS app I'm working on, I am using a service to periodically (in a $timeout) make a GET request to a URL in my API (both the Angular app and the API are being served from port 5000 on localhost).
For some reason, it appears that $http is not actually sending the GET. For each $http.get(), the .error() is called with empty data and a status of 0. When I check in my server log (I'm running a Ruby on Rails backend with the Unicorn gem for my server), it appears that the server never receives the request from Angular.
Here's the function in my service:
updateUserStatus = () ->
$http.get('/api/v1/status').success (statusData) ->
# update the variable and notify the observers
this.userStatus = statusData
notifyObservers()
startStatusTimeout()
.error (error, status) ->
# if there's an error, log it
console.log 'error:'
console.log error
console.log status
startStatusTimeout()
What's really odd is that it only happens sometimes. When it stops working, I can change the URL in the $http.get() to '/api/v1/status.json', and it works. For a while. Then I switch it back and it works again, for a while... obviously there is some greater issue at play.
I've been racking my brain for a few days now, and I've seen a bunch of similar issues on SO, but they all seem to be solved with implementing CORS in Angular, which I don't think is applicable to my situation because it's all coming from localhost:5000. Am I wrong? What's going on?
For reference, I'm using Angular version 1.0.7.
I had the same problem.
Check your code to see whether this happens after events that are fired from the DOM and are unknown to Angular.
If so, you need to add $scope.$apply(); after the get request in order to make it happen.
I'm fairly new to Angular so I'm not sure this is the best practice for using Angular, but it did work in my case.
See this similar question for a better explanation.
I've got a bit of a strange issue with iOS safari and backbone.js.
I am trying to fetch a collection via a post command, my backbone code is
MyApp.search_results.fetch({data: data,type: 'POST',
success: function(response){
//I do a bunch of stuff with success
},
error: function(){
alert('problem getting search');
}
});
when I run the above code in chrome (both desktop and in iPhone or Android) I get the result no problem.
But using safari on iOS, I get Failed to load resource: the server responded with a status of 404 (Not Found).
The big problem is my rails console does not even show that safari is sending the request, I see nothing past the previous request, so I'm getting a 404 error, but that actually isn't the problem.
Any ideas?
------------------------ update -----------------------
the problem is somehow caused by the type: 'POST'. I have removed and am now submitting a get request, but I would prefer this being a post type. So any suggestions on how to fix that would be great.
Backbone internally set's the request method to GET for the fetch function. Trying to override it can cause any number of inconsistencies and is not recommended.
If you're trying to fetch data, then why not update your server code to read the GET params instead of POST params (or both)?