Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have never actually learned how to create a blog or anything the like up to now. I would like to create a personal portfolio/homepage, which will load older articles as soon as the user pushes the "load more" button. Now, I have it all set up, but I don't really know how to keep track of the oldest article ID.
As mentioned, here I load articles from a php script via AJAX.
$('#more_articles_button').click(function () {
$.ajax({ url: kBaseUrl+"content_loader.php",
data: {
action: 'load_more_articles',
article_id: 'insert_lowest_article_id'
},
type: 'post',
success: function(output) {
$('#articles_container').append(output);
}
});
});
Here I would like to get the last article's id and send it to the php script. How do I get hold of it ?
Put the article id in the id's attribute of your article's div and a common class in them (say, 'article'), and, using JQuery, iterate through them to get the maximum value:
var max_id = 0;
$('.article').each(function(i, object) {
curr_id = $(object).attr('id');
if (curr_id > max_id)
max_id = curr_id;
});
//Afterwards, your ajax JQuery call
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last month.
This post was edited and submitted for review last month and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I have many google classroom invitations and I want to accept all of them through google app script using
Classroom.Invitations.accept("courseId");
but then I get no data back...
so I tried listing all my invitations using
Classroom.Invitations.list({"userId":"my_email"});
and still I get no data back...
I am very sure that my google classroom is full of unaccepted courses
Modification points:
In your script, an error occurs at var teacherEmails=(john.doe#gmail.com,jane.doe#gmail.com);.
I thought that your script might be for a python script. If you want to use this method using Google Apps Script, it is required to modify it.
When these points are reflected in a Google Apps Script, how about the following sample script?
Sample script:
Before you use this script, please enable Classroom API at Advanced Google services.
function myFunction() {
const courseId = "###"; // Please set your course ID.
const teacherEmails = ["john.doe#gmail.com", "jane.doe#gmail.com"]; // Please set email addresses.
teacherEmails.forEach(userId => {
const res = Classroom.Invitations.create({ courseId, userId, role: "TEACHER" });
console.log(res)
});
}
Reference:
Method: invitations.create
Call this method in Google App Script, you will need to use the Classroom.Invitations.create() function in your code and pass the necessary parameters.
function createInvitation() {
var courseId = '1234567890';
var userEmail = 'test#google.com';
var role = 'TEACHER';
var invitation = {
userId: userEmail,
courseId: courseId,
role: role
};
var response = Classroom.Invitations.create(invitation);
Logger.log(response);
}
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
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
When a user click's on a username on the list below, it's meant to open up the add user page with the name's of the user in the fields.
I get this error message:
Here's the code in the manage users page:
componentWillMount: function () {
var userId = this.props.params.id; // from the path /user:id
if (userId) {
this.setState({ user: userId.getUserById(userId) });
}
},
Here's the code in the userApi:
getUserById: function(id) {
var user = _.find(users, {id: id});
return _clone(user);
},
I am new to StackOverflow and programming, so if this post doesn't meet the community's guidelines, please guide me on how to better make use this platform so I can further my learning progression.
Thanks,
Rickie
Using the userId variable you can't call your API. Since getUserById is from your API you must call the method from there.
userApi.getUserById(userId);
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 6 years ago.
Improve this question
Is there any way to store a session using javascript variable and display on a label on another page? I'm using ASP.NET WebForms C#.
Thanks.
Depends on what you mean by "session" - as in "managed by ____".
As commented above, "sessions" can be managed by the server (safer, particularly if you want to have "full control" over what data be persisted)
but it's not the "only" place you can create "sessions". See WebStorage, if your needs can live on the client side of things.
Stating the obvious, it's client side so it can be manipulated (trivially) by the user/client so just like anything coming from the client, never trust (always validate/check).
Trivial example (must improve):
In some _Layout page (or master page, or some Javascript library for your site):
var ClientSession = function() {
this.setItem = function(key, value) {
sessionStorage.setItem(key, value);
}
this.getItem = function(key) {
return sessionStorage.getItem(key);
}
}
var mySessionBroker = new ClientSession();
In some other page where you set items for the duration of the browser session
<script>
window.mySessionBroker.setItem("key1", "hello from Index page");
//At this point, you should see that you can store something generated from the server
//and manage it from that point forward in javascript/client like so:
window.mySessionBroker.setItem("key2", "<%=HttpUtility.JavaScriptStringEncode(SomeServerVariable) %>");
</script>
In any other page on your site (same domain/protocol) where you want to use/display, etc. items set in sessionStorage
<p>Session data: <input id="someInput" name="foo" /></p>
<script>
window.onload = function() {
var target = document.getElementById("someInput");
target.value = window.mySessionBroker.getItem("key1");
}
</script>
You can use browser dev tools to inspect both sessionStorage and localStorage (goes without saying that as above, if you can, anyone else can - hence validate/inspect and don't use it for sensitive items).
Hth..
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to check on my website if user(visitor) has already clicked "like" on Facebook fan page, is it possible? I want to remove "like" button if user clicked "like".
In Facebook app I can check it easily with this code:
<?php
$request = $_REQUEST["signed_request"];
list($encoded_sig, $load) = explode('.', $request, 2);
$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);
if (!empty($fbData["page"]["liked"]))
{
//if liked do....
} else {
//else do....
}
?>
But how to use similar code on my website?
Use event subscribe method from FB api:
FB.Event.subscribe('edge.create',
function(href, widget) {
alert('You liked the URL: ' + href);
}
);
Another way for tracking is LikeButton data-ref. The ref setting causes two parameters to be added to the referrer URL when a person clicks a link from a stream story about a Like action:
https://www.facebook.com/l.php?fb_ref=top_left&fb_source=profile_oneline
When user click like, you will process _GET['fb_source'] parameter as you like at your website
To get statistics by url you can use link.getStats. It's method will return xml response with all statistics for url (including like). You cant get this statistics and manipulate as you wish
http://api.facebook.com/restserver.php?method=links.getStats&urls=https://www.facebook.com/myPage
http://api.facebook.com/restserver.php?method=links.getStats&urls=http://example.com