Refresher not working with $http.jsonp


#1

Hi Ionic, Just wondering why my ‘pull to refresh’ solution doesn’t work.
Could anybody see what’s wrong?

http://codepen.io/studentttt/pen/BNPPoP <- after pulling to refresh ‘test’ row should be replaced by data from json, but it freezes


#2

Hmm forgot to add factory: EventService.


#3

it is enough to create only one tpoic about a problem -.-
http://forum.ionicframework.com/t/ion-refresher-works-only-once/28666


#4

sorry, well you right… but don’t know how to remove the ‘older one’ (I’ve posted to admin to remove it).

Alright, but lets back to the issue… I’ve fixed adding data to database at http://codepen.io/studentttt/pen/BNPPoP
Now after added new row and pull to refresh noting happen, unless you refresh all the page.
anybody?


#5

i only get error that the request failed:
get pen.js:14 error: undefined/s: 404/c

But you have to call the complete-event if your request finishs.


#6

could you explain deeper ‘call the complete-event if…’?
Snippets you’ve provided also not working.


#7

$scope.$broadcast(‘scroll.refreshComplete’);

triggers a angularjs event.
This event is used by ionic to get noticed, if the refresh has finished. is does nothing more, than hinding the refresh-animation and reset it.

and the refresher works like expected.
But take a look at your request.
The first time success callback is called and after that the error-callback:


#8

Thats right… don’t know why after first hit another one is with error.
I’ve posted new question here: http://stackoverflow.com/questions/31504637/angular-http-jsonp-method-works-only-once <- will see.

Thanks


#9

strange thing… every request finishes with a 200 and the same repsonse, but $http jumps into error case

Why returns your api http://www.where2play.pl/index.php/json/getallusers angular.callbacks._0(…)?
AngularJS will convert your response to that automatically if you change your json-p url to:
$http.jsonp(‘http://www.where2play.pl/index.php/json/getallusers?callback=JSON_CALLBACK’)


#10

without ‘angular.callbacks._0(’ in server response the $http jupms every time into error clause :slight_smile: quirk


#11

Alright… forgot to retrieve the callback parameter dynamically from the request URL. So far I’m having always ‘angular.callbacks._0’ but it can be also angular.callbacks._1, angular.callbacks._2 etc.

Thanks for help benglter.


#12

correctly… and with ?callback=JSON_CALLBACK you set something like a placeholder and if the request works --> angularjs calls the success callback