Ajax and Security Pitfalls - ajax

Some time ago I start to work with Ajax, and I realy want to learn the right way to use it. My websys load the content with Ajax but I noted that if I change the HTML link code in Chrome or any other Nav the requisition will be done any away. My question is what is the right way to secure and verify the acess of links, and how I can do that with CI Framework and Ajax. My idea is verify with session integrating that with ajax loading the content based on the permission of user, but I don't know where I put that code in MVC Controller structure and how integrated that with the view/Ajax. I appreciate if someone could share some example code because I don't have any clue to solve that puzzle.

Related

How to implement Ajax for my wordpress site?

I'm really confused.
I just desire to implement ajax in my wordpress site: clicking on each link of the menu or on each post, I'd like to show dinamycally the content in the main wrapper of the website (and at the same time I'd like to see the url changing everytime for each page or post).
I have made a research through Google and I found a multitude of tutorials or informations but each one of them is (for me) like incomplete.
Can you suggest me a good tutorial?
Or can you explain me what are the best solutions?
I read somewhere of "Ajaxify", a plugin, can it help me?
Be patient, I have always had some difficulties with ajax and in wordpress things seems to become even more complex.
I guess this tutorial can help you: http://www.designlunatic.com/2011/06/dynamically-load-wordpress-posts-with-jquery/

when to use AJAX and when not to use AJAX in web application

We have web applications elgifto.com, roadbrake.com in which we used AJAX at many places, especially to update major portions of a page. All the important functionality of elgifto.com was implemented using AJAX. Now we realize a few issues due to AJAX implementation.
All the content implemented using
AJAX is not available to the SEO
bots and it is hurting the page rank
of our site.
Users will not be able to bookmark
some of the pages as they are always
available through AJAX.
When we want to direct the user from
one page through an anchor link to
another page having AJAX, we find it
difficult.
So now we are thinking of removing AJAX for these pages and use it only for small functionality such as something similar to marking a question as favorite in SO. So before going ahead and removing, we want to know expert's opinion on this. Thanks.
The problem is not "AJAX" per se, but your implementation of it. Just as a for instance, you can fix the 'bookmark' problem like google maps does it: provide a generated link for each state of your webapp.
SEO can befixed by supplying various of these state-links to the crawlers, either organically trough links in your site, or by supplying a list (sitemap).
If you implement 2, you can fix 1 and 3 with those links.
In the end you must figure out if the effort is worth it, and if you are not overusing AJAX ofcourse, but the statements you've made are not set in stone at all.
I'm costantly developing ajax based websites, with no problems for SEO at all. You just have to use it in the best possible way.
For example, I have a website with normal links pointing to normal webpages (PHP pages), this for normal navigation if a user doesn't have JS enabled. But if a user has JS enabled, a script will change the links behavior, only fetching the content of the page needed.
This way you still have phisycal separated webpages with all their content, which will be indexed as normal.

Upload an image using jquery AJAX in .net MVC

I am creating one application in .net MVC, in which I am using jQuery AJAX to post some data to server. The data posting is working fine, but I also need to upload one image along with the data. I have searched on stack over flow for similar question but they are not able to help me. I donot want to use flash to upload file, pure jquery solution will help me.
Using some solution I tried to post to server, but on server side I am not getting file data.
Please can some body tell me how to implement file upload in jQuery ajax?
Thanks
Ashwani
I think you're out of luck if you want ajax like uploading without flash. Due to security limitations javascript can't do all the things required. Off the top of my head i'd say your only other option will be to use an iframe to make it appear as thought it was an ajax post.
Why not use flash though? YUI Uploader is amazingly simple and works great!

Spider/Crawler for testing an AJAX web app that requires a session cookie?

We have a web app that is heavy on AJAX and it is very customizable so we need something that will click on every link in it to make sure that none of the forms/pages break. I know that there are lots of spiders/crawlers out there but we haven't been able to find one that's easy to implement and works with AJAX and allows you to have a session cookie.
Well, considering you asked this question over two years ago I doubt you'll have much need for the answer. But in case someone else comes across this question from a search engine, here's my suggestion:
Use Selenium http://seleniumhq.org/ or IEUnit https://code.google.com/p/ieunit/ to automate a browser itself. They both operate on top of a JavaScript engine so you can write a few lines of code to click on every anchor tag in your site.

How is AJAX implemented, and how does it help web dev?

From http://en.wikipedia.org/wiki/AJAX, I get a fairly good grasp of what AJAX is. However, it looks like in order to learn it, I'd have to delve into multiple technologies at the same time to get any benefit out of it. So two questions:
What are resources that can help me understand/use AJAX?
What sort of website would benefit from AJAX?
If you aren't interested in the nitty gritty, you could use a higher-level library like JQuery or Prototype to create the underlying Javascript for you. The main benefit is a vastly more responsive user interface for web-based applications.
There are many libraries out there that can help you get benefit out of AJAX without learning about implementing callbacks, etc.
Are you using .NET? Look at http://ajax.asp.net. If you're not, then take a look at tools like qcodo for PHP, and learn about prototype.js, jquery, etc.
As far as websites that would benefit: Every web application ever. :) Anything you interact with by exchanging information, not just by clicking a link and reading an article.
Every website can benefit from AJAX, but in my opinion the biggest benefit to AJAX comes in data entry sections - forms basically. I have done entire sites where the front end - the part the user sees had almost no AJAX functionality in it. All the AJAX stuff was in the administration control panel for assisting in (correct!) data entry.
There is nothing worse than submitting a form and getting back an error, using AJAX you can pretty much prevent this for everything but file uploads.
I find it easiest to just stay away from all the frameworks and other helpers and just do basic Javascript. This not only lets you understand what's going on under the covers, it also lets you do it in the simplest way possible. There's really not much to it. User the JS XML DOM objects to create an xml document client side. Sent it to the server with XMLHTTPRequest, and then process the result, again using the JS XML DOM objects. Start with something simple. Just try sending one piece of information to the server, and getting a small piece of information back.
The Mozilla documentation is good. Sites that benefit from it the most are ones that behave almost like a desktop application and need high interactivity. You can usually improve usability on almost any site by using it, however.
Ajax should be thought of as a means to alter some content on a page without reloading the entire page.
So when do you need to do this? Really only when you have some user interactions or form information that you want to keep intact while you change some content on the page.

Resources