Archive | Javascript RSS feed for this section

Are you handling Ajax Error ?

Yesterday I was working on an existing project developed by other company. One of my task was “Ensure that all ajax actions time out gracefully ” . In my programming career first time I see this type of task. Why? Because the other programmer who work for that company, don’t know or don’t care to write error handler code during ajax call.

But luckily they used jQuery for ajax related tasks, and that’s why its really easy for me to fix this. Normally using jQuery when I do ajax related tasks I use the following way jQuery.ajax()

jQuery.ajax({
           type: "POST",
            url: "ajaxurl.php",
           data: somedata,
           success: function(msg){
              //success task
           },
           error: function(xhr, statusText, errorThrown){
              //error handler to show a specific message
           }
         });

But that programmer used jQuery.post() to do ajax task

Continue Reading →

Comments { 2 }

Create Facebook PopUp Authentication Window using PHP and javascript

facebookSome days ago one of my friends Paul Espino asked me that he is facing a problem of redirection loop.  He followed exactly my article php sdk & graph api based fb connect tutorial but in his server when user logged in via facebook connect by clicking javascript base fbconnect button the login() method of below code called again and again

FB.Event.subscribe('auth.login', function(response) {
    // do something with response
     login();
});
function login(){
    document.location.href = "<?=$config['baseurl']?>";
}

I tested the code in various server but the problem occurs only in his server. Then I think to solve the problem using php-sdk generated login code.

Continue Reading →

Comments are closed

iframe based photo/file uploader

iframesuppose your client tell you to create a form where he needs file/photo uploader that will work instantly when you will select file/photo.

recently i’ve faced same type of situation for one of facebook app and here is the solution i developed for my purpose.

part_of_form_1

Continue Reading →

Comments { 15 }

pre-launch checklist before make your site live

checklistsometimes we the developers, up our site live and face some problems. this is very often happen when deadline comes nearer. if we maintain a pre-launch checklist before make our site live then we may not face such problems like:

  1. Error Management: check whether your site has a 404 not found page that includes
    links to functional pages. this may happen when you port an existing site to some major changes. so include some pages links to this page so that user can easily find the working page.
  2. Continue Reading →

Comments { 2 }

Firebug – An essential tool for web developer

As a web application developer, sometimes we need to debug javascript code or need to make some css design. In Mozilla firefox web browser there is a plugin named Firebug, that integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

To install Firebug visit the Firebug download page. Click on the huge orange button half-way down the page on the right hand side. You can also download it from Mozilla’s FireFox Add-ons site. Install it. Restart FireFox, and you’re good to go.

Opening and Closing Firebug

Keyboard and Mouse Shortcuts for Firebug can be found at the Firebug Website. The three sets I use most often include:

  • Open Firebug: F12 or clicking on the green check mark at the right of the right of the browser status bar.
  • Close Firebug: 12 or clicking on the green check mark at the right of the right of the browser status bar or clicking on the red x in the upper right hand corner of the firebug window.

Inspect and edit HTML

Firebug makes it simple to find HTML elements buried deep in the page. Once you’ve found what you’re looking for, Firebug gives you a wealth of information, and lets you edit the HTML live.

Tweak CSS to perfection

Firebug’s CSS tabs tell you everything you need to know about the styles in your web pages, and if you don’t like what it’s telling you, you can make changes and see them take effect instantly.

Debug and profile JavaScript

Firebug includes a powerful JavaScript debugger that lets you pause execution at any time and have look at the state of the world. If your code is a little sluggish, use the JavaScript profiler to measure performance and find bottlenecks fast. Firebug provides the console object that has several methods usable for logging. Properties of console object include console.debug, console.info, console.warning, and console.error. When one of these methods produces an output, Firebug links to the line causing the output so you can quickly find the responsible code.

Logging for JavaScript

Having a fancy JavaScript debugger is great, but sometimes the fastest way to find bugs is just to dump as much information to the console as you can. Firebug gives you a set of powerful logging functions that help
you get answers fast.

Comments { 0 }

History.. PHP .. MYSQL .. JQUERY

PHP

Rasmus Lerdorf” – The creator of PHP Scripting language.
http://en.wikipedia.org/wiki/Rasmus_Lerdorf
http://lerdorf.com/bio.php
http://www.oracle.com/technology/pub/articles/php_experts/rasmus_php.html

MYSQL

Michael Widenius” – Founder and original developer of MySQL
http://monty-says.blogspot.com/

JQuery

John Resig” – The creator and lead developer of the jQuery JavaScript library.
http://ejohn.org/about/
http://ejohn.org/blog/

Comments { 0 }

JSON -A lightweight data-interchange format

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

Visit: http://www.json.org/

Comments { 0 }

AJAX -Simple to implement

Hello,
I found Prototype.js http://www.prototypejs.org/download is a nice tool for implementing ajax. You could use it in any framework. Just download the file, and load that by <script src=””>. Then implement the following code
A typical example to how to use ajax:
Ajax.Request is the main function here.
<script type=”text/javascript” language=”javascript”>
function myProcess(action)
{
url = “”;
url = url + ‘startPHP.php’;
pars = ‘action=’ + action;
myAjax = new Ajax.Request(url, {method: ‘get’, parameters: pars, onLoading: showLoad, onComplete: showResponse, onError: showError} );
}
function showLoad()
{
$(‘content’).innerHTML = ” What you want to show”;
}
function showResponse(response)
{
var newData = response.responseText;
$(‘content’).innerHTML = newData;
}
function showError(ale)
{
alert(ale);
}</script>
Comments { 4 }