What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [RESOLVED] Using Ajax.open to get specific div

[RESOLVED] Using Ajax.open to get specific div
Author: Message:
macgyver08
Junior Member
**

Avatar
Hakuna matata!

Posts: 23
34 / Male / Flag
Joined: Feb 2007
O.P. [RESOLVED] Using Ajax.open to get specific div
I know a little javascript to get me by on small projects, but I'm new to Ajax. I've looked at all the threads on this site with "Ajax.open" but I can't figure out what to do.

I want to use Ajax in a Plus! Live script* to get the text between a specific div tag on this page...

http://macgyver89.webs.com/ajax_test.html

and then send it to a user through an instant message*. "1. test111" is between <div id="1"></div>, and so on.

Can anyone help?

I want it to do something like this script (click here). Instead of the text on the site being grabbed and being displayed in a personal message though, I want the text (from a specific div) on my site to be sent through an instant message on command.*

* = edited

This post was edited on 01-30-2010 at 12:07 AM by macgyver08.
01-27-2010 06:57 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Using Ajax.open to get specific div
what do you mean send it to a user? e-mail?

I would suggest jquery (javascript library) would be probably the best way to do this as it has a built in, simple ajax function and selectors to get the right element easily (very flexible) and a function to read the contents of the div...

Although, if you do want to use email, You'd need to find a way to pass the javascript variable to PHP, which IIRC needs to be done through some sort of form.
<Eljay> "Problems encountered: shit blew up" :zippy:
01-27-2010 08:08 AM
Profile PM Find Quote Report
macgyver08
Junior Member
**

Avatar
Hakuna matata!

Posts: 23
34 / Male / Flag
Joined: Feb 2007
O.P. RE: RE: Using Ajax.open to get specific div
quote:
Originally posted by Spunky
what do you mean send it to a user? e-mail?

I would suggest jquery (javascript library) would be probably the best way to do this as it has a built in, simple ajax function and selectors to get the right element easily (very flexible) and a function to read the contents of the div...

Although, if you do want to use email, You'd need to find a way to pass the javascript variable to PHP, which IIRC needs to be done through some sort of form.
Thanks for replying :)

No, not e-mail, through an instant message.

I've never heard of jquery, so I don't know if I'd even know how to use it, but look at this script:

http://shoutbox.menthix.net/showthread.php?tid=73...d=810875#pid810875

I want it to do something like that. Instead of the text on the site being grabbed and being displayed in a personal message though, I want the text (from a specific div) from my site to be sent through an instant message on command.

This post was edited on 01-27-2010 at 09:58 AM by macgyver08.
01-27-2010 09:57 AM
Profile E-Mail PM Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
37 / Male / Flag
Joined: Mar 2006
RE: Using Ajax.open to get specific div
quote:
Originally posted by macgyver08
This is a scripting question! Some mod moved it from
Scripting to Tech Talk for some reason, so don't ask
why I posted it here, because I didn't
.



The scripting section of the website is for Messenger Plus! Live scripting.  Your question is a "Tech Talk" enquiry as it isn't to do with Messenger Plus! Live, it's just general technology enquiry :)
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5215 days, 20 minutes, 55 seconds ago
01-27-2010 10:49 AM
Profile E-Mail PM Find Quote Report
macgyver08
Junior Member
**

Avatar
Hakuna matata!

Posts: 23
34 / Male / Flag
Joined: Feb 2007
O.P. RE: RE: Using Ajax.open to get specific div
quote:
Originally posted by djdannyp
quote:
Originally posted by macgyver08
This is a scripting question! Some mod moved it from
Scripting to Tech Talk for some reason, so don't ask
why I posted it here, because I didn't
.



The scripting section of the website is for Messenger Plus! Live scripting.  Your question is a "Tech Talk" enquiry as it isn't to do with Messenger Plus! Live, it's just general technology enquiry :)
Hmm...the solution to my problem was going to be utilized in a Plus! Live script. I guess I didn't make that clear. Well...wherever you think it fits best in is fine I suppose. I was just afraid that most of the scripting people would be in the scripting section, and that my question wouldn't get the best attention being in Tech Talk.

Thanks.

This post was edited on 01-27-2010 at 11:12 AM by macgyver08.
01-27-2010 11:05 AM
Profile E-Mail PM Find Quote Report
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: Using Ajax.open to get specific div
I think that you may be looking at this the wrong way.  Instead of parsing your site to extract the text from a specific <div> it may be much simpler to have your site provide the same text in a more handy format, such as a .txt file or a web service.  If it is "your" site, you should have the ability to set this up.

If it isn't your site, the functionality you are talking about is called "web scraping" and looking that up may yield some helpful information.
01-28-2010 07:59 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Using Ajax.open to get specific div
A simple and crude method would just to be:

Javascript code:
// txt is the xmlhttp responseText stored in a variable
txt = txt.split('<div id="1">')[1];
txt = txt.split('</div>')[0];
// txt will now be the div contents including the html
// if the content is bold for example, you will see:
// This is the <b>content</b> from the div


EDIT:
It may be possible to do this in one line:
Javascript code:
txt = txt.split('<div id="1">')[1].split('</div>')[0];


I can't be sure of that one though without trying it, but most javascript seems to chain quite well

This post was edited on 01-28-2010 at 09:47 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
01-28-2010 09:45 AM
Profile PM Find Quote Report
macgyver08
Junior Member
**

Avatar
Hakuna matata!

Posts: 23
34 / Male / Flag
Joined: Feb 2007
O.P. RE: Using Ajax.open to get specific div
quote:
Originally posted by Adeptus
I think that you may be looking at this the wrong way.  Instead of parsing your site to extract the text from a specific <div> it may be much simpler to have your site provide the same text in a more handy format, such as a .txt file or a web service.  If it is "your" site, you should have the ability to set this up.

If it isn't your site, the functionality you are talking about is called "web scraping" and looking that up may yield some helpful information.
quote:
Originally posted by Spunky
A simple and crude method would just to be:

Javascript code:
// txt is the xmlhttp responseText stored in a variable
txt = txt.split('<div id="1">')[1];
txt = txt.split('</div>')[0];
// txt will now be the div contents including the html
// if the content is bold for example, you will see:
// This is the <b>content</b> from the div


EDIT:
It may be possible to do this in one line:
Javascript code:
txt = txt.split('<div id="1">')[1].split('</div>')[0];


I can't be sure of that one though without trying it, but most javascript seems to chain quite well
Thanks to both of you! I've got it figured out now :D
01-28-2010 10:46 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On