GPS while phone locked or in the background not sending to DB

I set up an interval to send my current GPS coordinates to the database. My problem is that the GPS does not sends GPS when locked or when I view other apps on my phone. I put backgroundMode.enable();
but still not working(note: and when I go to my app and check the DB , it just starts sending so meaning the background mode did not worked), by the way I used jquery.ajax to send my gps let me know if you want to view my code on how I get my latlng. Please help thank you in advance!

So sir you meant that backgroundmode.enable(); is not working with navigator.geolocation.getcurrenposition thats why you prefer me to get a background GPS? because backgroundmode enable became redandunt If I were to change it.