0

So I'm not that great with javascript, but I'm trying to make a mail notification or this sort of things.

So far I'm using gmails xml file that will display the number of unread emails under a fullcount tag. I want to fetch this with javascript and display it on a html page. Is there a better way to do this?

So far I've come up with this:

HTML:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test</title>
        <link rel="stylesheet" href="style.css">
        <script src="gmail.js"></script>
    </head>
    <body onload=getgmail();>
        <div id="container">
            <div id="gmail">
                <p id="mail">0</p>
            </div>

        </div>
    </body>
</html>

Javascript:

function getgmail() {

    //loadpage
    $.get("https://USERNAME:[email protected]/mail/feed/atom", function(data));

    //get variable inside fullcount tags
    var mailcount= document.getElementsByTagName('fullcount');

    //output variable to html
    document.getElementById('mail').innerHTML = fullcount;

}

I'm probably doing it completely wrong and I would appreciate your help! thanks

0

1 Answer 1

1
function getgmail() {

    $.get("https://USERNAME:[email protected]/mail/feed/atom", function(data) {
        var mailcount = data.getElementsByTagName("fullcount")[0].textContent;
        document.getElementById('mail').innerHTML = mailcount;
    );

}

You should check out $.get() API documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.