How does Yahoo's new automatic loading work? - javascript

In the new Yahoo mail inbox, when u click the message it is displayed in a tab automatically (I guess with out server interaction). Does that mean Yahoo loads all the data first and then use them with java script when requested or not...anyho i don't have any idea and I would like if some one explain to me how it works since am planning to do the same with my application. I am sure this will boost application performance and i am eager to know.

I guess Yahoo did something similar to what Hotmail describes here
Basically they decide depending on several aspect what+when to preload...

I have not seen it but what you're describing sounds like dynamic AJAX loading. Basically, only load information when it is requested by the user. This will reduce network load and initial loading times. Most JS libraries have some form of AJAX helper. You can read more on AJAX here and here.

I am pretty sure it does have some server interaction. It definitely is using some sort of AJAX to fetch data from the server and show it to you. There are tons of tutorials about using AJAX which you can refer. You can probably start with http://w3schools.com/ajax/default.asp

Related

Get parameter from another page using javascript?

I have a wordpress site, and i'm not a php developer and not very eager to start either so I'm avoiding it like the plague, but I do have a requirement that requires a little bit of extra coding. I need to:
go to a different website,
download that page,
check for a certain phrase,
if phrase exists, extract a link from that page
and if link is returned I need to show that link on my wordpress site.
Currently, I have an asp.net page that does this and i'm hosting that page in an iframe on my wordpress site. but i'd like to do it without an iframe.
Question is, is there anyway for javascript to go to a different page (my asp.net page) and get a parameter (link) from it. If link is provided i will show certain content on wordpress site.
Or can javascript download a text file from the server? problem with that is i need a trigger to update the text file.
Any advice is appreciated.
Thanks.
What you should understand is that by "avoiding [PHP] like the plague" you're inadvertently avoiding the proper way of doing things. Javascript is a client-side language, and PHP is a server-side language. By asserting that you only want the load on the client's end (the kind of logic involved in what you want to do isn't exactly lightweight), you can potentially end up with a VERY slow webpage.
Not to mention, this type of situation is analogous to using a hammer to do a backhoe's job.
Either way, to answer your question, yes. You can use the jQuery Load method in tandem with Javascript's Match method.
What you should TRY to do, however, is make a CURL request using PHP, and then cache the page on your server. By doing this, you will limit the number of calls to a given page, and optimize load times.
Please consider the second option, even as an attempt in good practice. Good luck.
Use ajax and connect to a different page (on your server) which is written in server-sided language (like asp.net, as you said), that connects to the remote website.
More about Ajax

call live webservice from simple html page...?

I read lots of post here, but don't get specific answer.
I have live server on which I have my web services work properly.
now, I want to create one simple html page through which I call that web service.
with javascript this is possible but what is exact.
I repeat again only html and javascript through which I want to call that web service.
you can use jquery to load the data from webservice, but you might need to include jquery js file and your browser(IE) might prompt for security violation and you might need to click yes.

save entere webpage using ruby (clojure or javascript)

I've got a problem. I'm working with a food supplier and I need save the content of each order as html. Orders are listed on a single page as links, but this has 2 difficulties
Page uses authentication (need to log me in in advance)
This is the real problem: the page use a lot of javascript. Actually everything works without changing the web address so I can't use wget or rio gem (url not like www.fooddoe.com/order, www.fooddoe.com/order/1, etc. but always like www.fooddoe.com/suplierx).
I think firewatir would be a good option but the problem is than I need to save the page in a format similar to html (including images). Is it possible using firewatir? Are there other options in clojure or javascript?
Thanks so much!!
I had to read your question twice to understand what you mean.
From web address from example I assume this is yours supplier web page. So IMHO the easiest way is:
Look into source of web page to get an idea how it gets the data (99% for some kind of AJAX request).
Request goes to the server which responds to it.
Now there are two ways:
Get idea how the request is made and write and app to make such request and generate web page with it (more difficult, more general)
Contact your supplier and get original database (simpler but one-time solution)
And I think that this is not the question specific to any language.

Security Request for JSon Result in Asp.Net MVc

I developed an application in ASP.NET MVC. This app has an action that returns a JsonResult and I get it with jquery in client side. Everything works fine but I'd like to know, if is there any way to make a security in this action to return only requests that came from my website.
Is there any way to avoid others websites to request this action? Or avoid javascript in address bar (script injection) ?
Thanks
Short answer: No
Long answer: The only way to know that a request is legitimate is to interpret what's coming with the request. There's no magic in the http protocol. Probably, the most reliable way is to check the referrer and ensure that it's your site. But it's not hard to fool that check..
I have not tried this yet but have been thinking about how I might achieve this as well. My current thoughts are to add a custom attribute to the action that checks a token appended to the cal by the requesting application.
The token would be generated by the calling application based on a seed key that was provided to the requester upon applying to use the API. The custom attribute would authenticate the key before the action ran either allowing or denying the call.
As I said not fully formed yet but was thinking along these lines ... good luck and if you come up with something make sure you post back.
For other sites:
You can check the referrer, but that can be spoofed.
You can check to see if you have an active session with the user.
For the address bar:
There is nothing you can really do about that.
Others Websites can't make requests to your action using ajax because HTTP doesn't allow it, but it can still get called from the address bar, other program or anything.
If you whant to allow calls to your action only from specific parts of your website you can use the the html helper AntiForgeryToken and the attribute [ValidateAntiForgeryToken], you can check a tutorial about this over here: http://haacked.com/archive/2009/04/02/anatomy-of-csrf-attack.aspx. It's pretty much the idea abarr posted.

Notify user on database change? JavaScript/AJAX

Yo.
I'm really quite new to this whole JavaScript business, not to mention AJAX, so I was thinking if you guys could help me out with a conundrum.
Basically, what I want is for the user to be notified upon a change in a value of a MySQL table. How should I go about that? Should I use jQuery, or can I slap something together myself?
Thankful for any and all replies.
Depending on how quickly you need the users to be notified, you could use either polling (sending a request every X seconds to see if there's anything new) or use comet.
In any case, you'll need a server side programming language to be querying the database and serving the results, and you'll need some javascript on the client-side to be sending requests and displaying responses. I would highly recommend using the jQuery library, since it simplifies a lot of cross-browser incompatibility.
Well, this is a bit abstract, but there are two parts to this: a server-side script, and your AJAX code (which sends this request to the script). Your server-side script will actually be doing the query to see if the database has changed, so your JavaScript will have to have a periodic execution (say once every ten seconds or whatever interval is right for you) if you are not waiting for the user to refresh their page.
The chain of events will look something like this:
AJAX -> Script -> DB -> Script -> AJAX -> Update Web Page
You will definitely want to use jQuery, Prototype, or some similar framework if you are new to AJAX. It will save you tons of time.
You should use jQuery and jQuery ajax method http://api.jquery.com/jQuery.ajax/
In the HTML page, the JavaScript will use AJAX to keep requesting a backend page during a certain interval.
The backend page will check if a MySQL database was changed.

Categories

Resources