It isn't illegal.
is it allowed to ask if someone can give me a membership?

Isn't begging kind of spamming
Beg once is not considered spamming.
Begging multiple times is considered spamming.
There is a difference.

But if you start writing the same thing multiple times or sending the same message to multiple people other than club invitations is considered spamming.

You put in information like a card number and stuff like that in order to pay money to gift somebody a gold, platinum or premier membership.

Isn't begging kind of spamming
Beg once is not considered spamming.
Begging multiple times is considered spamming.
There is a difference.
This is correct. Asking for a membership might get ignored by many people and come across as kind of pathetic, but that doesn't make it "illegal." Spamming on the other hand, that is against the rules of chess.com tos.
Even if you are caught spamming unethically though, that doesn't necessarily mean you'll be banned; more likely is a warning or temporary mute.
I had the free chess.com membership for years and I really wanted a higher membership, but I never asked others in the forums to gift me one. I just constantly seeked out chess.com tournaments and clubs and forum games etc. where they offered membership prizes. Back in the day, several chess.com clubs would gift memberships for a week or a month etc. as prizes for forum games or other things. Unfortunately, those are much more rare nowadays, but luckily there are still some generous membership gifters and membership prizes available if you are determined and looking for them.
I've also been gifted a membership by a few people unexpectedly over the years as well and I'm still grateful to those people for that
Luckily for me, I now have Diamond membership on my own; I know the "struggle" of not having a premium membership though.

Yeah. I'm sorry about this. I was so dumb. I was just so excited, I couldn't control myself ugh. I might get a diamond membership for my birthday. Sorry guys!
SITUATION CLEARED.

Yeah. I'm sorry about this. I was so dumb. I was just so excited, I couldn't control myself ugh. I might get a diamond membership for my birthday. Sorry guys!
SITUATION CLEARED.
It would be pointless if you don't use it to your full advantage. When I had diamond for a month, I grinded puzzles. If you are just going to flex your flair and not even use it, I did rather you don't buy premium/gold/diamond at all.
But I didn't know it was illegal!