How to use $timeout function to send data to server side on portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 10:40 PM
Hi All,
I am trying to send from the client controller to the server side, I am getting the data on change of field which is a choice list on portal which is a HTML Field.
So i tried without $timeout the data is not coming properly so i am using $timeout. i have used console to check if value is correct on client side. I am getting error as "cann't read properties of undefined reading get "
c.hostname= function(){
var host;
$timeout(function(){
host=c.hostname;
this.server.get({
action: 'getvaluefromserver',;
name:host;
}).then(function(response) {
c.cloudedata=response.data.cloudpro;
console.log("data"+response.data.cloudpro)
})
}, 5000); // 5000 milliseconds = 5 seconds
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 10:44 PM
Utilize the $timeout function in AngularJS to delay sending data to the server-side on a portal. This allows for asynchronous processing, ensuring smooth user experience by avoiding blocking operations while transmitting data to the server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 09:06 PM
how do i send values from client controller to server side by using $timeout, as i am getting error "can't read properties of undefined reading get "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 12:12 AM
Hi @Priya75
It seems like there are a couple of syntax errors and potential issues in your code snippet. Let's correct them:
c.hostname = function() {
var host;
// Assuming '$timeout' is injected properly into the controller
$timeout(function() {
host = c.hostname; // This line seems incorrect, it's trying to assign 'c.hostname' to 'host' which seems unnecessary
this.server.get({
action: 'getvaluefromserver', // Remove the semicolon here
name: host // Remove the semicolon here and use a comma instead of a semicolon to separate key-value pairs
}).then(function(response) {
c.cloudedata = response.data.cloudpro;
console.log("data: " + response.data.cloudpro);
});
}, 5000); // 5000 milliseconds = 5 seconds
}
Please mark as Accepted Solution & HIT helpful if it suffices..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 12:38 AM - edited 03-01-2024 12:39 AM
still getting the same error "can't read properties of undefined reading get".