Use postMessage to send variable value [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
I got a variable let data = 'testing...123' on a child site, and I embed this page on the parent site by an iframe.
How do I use the API postMessage to send the value of data to the parent site?
Assume I got a paragraph .textHere on the parent site and I want to use the variable from the iframe ( the child site ) on the parent site:
const elm = document.querySelector(.textHere);
function myFunction() {
elm.textContent = data;
}
The explanation from MDN is too deep and I do not understand:
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

on Chile iframe
window.parent.postMessage(
{
val: 'testing...123'
},
"*"
);
on parent
window.addEventListener('message', function(event) {
console.log(event.data.val);
});

Related

Implement loader with a timeout in Javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm basically calling data from an API and handling the data loading with a loader in my html so when my data array.length is not undefined, the data is shown.
But when there is no data it loads indefinitely...
What I want to do is set a timeout if there is no data, something like 10 seconds in order to display a message like "No data found"
Here is my Vue.js template:
If you search how to print a message after 10 seconds, there is this code:
function stateChange(newState) {
setTimeout('', 10000); //10sec * 1000
if(newState == -1) {
alert('NO DATA');
}
}

How do I fetch user data from firebase without being logged in? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I made a blog which has a database structure as shown below
users:{
$uid:{
Posts:{
$post_id: {...}
}
}
}
I'd like to have a public page where everybody can read the post without being logged in.
How do I fetch the data from firebase as it's clear I need the user id to go deeper
You should change the structure to the following:
users
uid
name : john
age : 100
posts
postId
userId : uid
post: post_content
Then you can do the following:
let ref = firebase.database().ref("posts");
ref.on("value", ((snapshot) => {
snapshot.forEach((childSnapshot) => {
let childData = childSnapshot.val();
console.log(childData.post);
});
});
childData.post will contain all the posts under posts node.

Get document collections in Firestore [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
this is my firebase database
- conversations (collection)
-- xxx (document)
--- users (collection)
---- xxx (document)
I want to list all the conversations and its users
this.db.collection('conversations').get().then(querySnapshot => {
querySnapshot.docs.forEach(doc => {
console.log(doc.collection('users').get())
});
});
I´m getting doc.collection is not a function
update: this is what I have after getting the id and making a new query. now the question is. is this performant?
this.db.collection('conversations').get().then(conversationsQuerySnapshot => {
conversationsQuerySnapshot.docs.forEach(doc => {
this.db.collection('conversations').doc(doc.id).collection('users').get().then(usersQuerySnapshot => {
usersQuerySnapshot.docs.forEach(doc => {
console.table(doc.data());
});
});
});
});
You're looking for doc.ref.collection('users'), since you need go get from the DocumentSnapshot to its DocumentReference through doc.ref.
Note that I find it easiest to spot such mistakes by simply following the types. Your querySnapshot is a QuerySnapshot, which means that your doc is a QueryDocumentSnapshot. Since QueryDocumentSnapshot doesn't have a collection method, it's easier to figure out what's going wrong.
you would call it: db.collection('conversations').doc({docID}).collection('users')
Your current query is set up to look through every conversation and then get every user in each of those. Plus the second part (getting the users) has no base document to pull from, which is why you're seeing an error.
I recommend watching this video

How to send pdf file thorugh email id using html,javascript and php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In my HTML form the user request to loanform.pdf link...while clicking the link it ask user email id after that pdf form send through user mail id.........how ll solve this can anyone gives some suggestion or example?
$email = new PHPMailer();
$email->From = 'you#example.com';
$email->FromName = 'Your Name';
$email->Subject = 'Message Subject';
$email->Body = $bodytext;
$email->AddAddress( 'destinationaddress#example.com' );
$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
$email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
return $email->Send();
Download the PHPMailer script from here: http://github.com/PHPMailer/PHPMailer

how to post a status in a group using Facebook graph explorer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Https://graph.facebook.com/v2.3/238155829716205
I want to post a status in open group what will be the query using facebook graph api thankyou
Have a look at the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/group/feed#publish
The call is the following
POST /v2.3/{group-id}/feed
with the appropriate fields included.
FB.api(
"/{group-id}/feed",
"POST",
{
"message": "This is a test message"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);

Categories

Resources