[jQuery] Re: Call ajax on sucess response from a previous ajax

2010-01-20 Thread Bonji
Ok basically on click of any anchor tag this ajax script calls a php
script called sessions.php

//data
   var data = 'do=update';
//run ajax
$.ajax({
//post rather than get (default)
type: "POST",
//pass to php script
url: "/php-bin/sessions.php",
//send data
data: data,
//data type
dataType: 'json',
//timeout
timeout: 5000,
//cache
cache: true,
//success function
success:
//result function
function(result){
//if result.error
if(result.error)
{
//redirect
location.href=result.redirect;
}
},
//error function
error:
//error function
function(){
//load facebox internal error
faceboxURL('php-bin/alert.php?do=internalError');
}
});//ajax

It posts 'do=update' as data to the php script which selects the
correct php switch.

The php script then checks if the user is logged in and updates the
users timestamp. All session data is stored in a mysql database.

The datatype returned is in a json array.

So on success the ajax checks the array value 'result.error' and if
set to true it currently redirects the user to the 'result.location'
value which is defined in the json array.

In other words... if the user was not found or their session has
expired it redirects the user to the location set in the php script as
they need to be authenticated to use the site.

However this means that the anchor tag is only checking user data.
What about its original function which is also an ajax call?

I thought i might be able to add the second ajax call as an else
statement to the if(result.error) statement.

In other words... if the user is authenticated and the timestamp was
updated run the origianl anchor tag function (which is also an ajax
call)

At the moment the two ajax calls run at the same time which is fine
except the second ajax is used to load content to the page. The first
ajax call completes half way through the second ajax call cycle.

In other words... if the user was not found or their session has
expired the second ajax still loads content to the page but gets cut
off half way through loading while the first one is redirecting.

This is ok but it is scrappy looking to see the page trying to load
content into a div (second ajax) while the first is redirecting.

I hope i havn't lost you. I've tried to explain as clearly as i can.

Ben



On Jan 20, 4:53 pm, Michael Lawson  wrote:
> Do you have any code to share?
>
> cheers
>
> Michael Lawson
> Development Lead, Global Solutions, ibm.com
> Phone:  1-276-206-8393
> E-mail:  mjlaw...@us.ibm.com
>
> 'When seen from outer space, our beautiful blue planet has no national
> boundaries.'
>
> http://www.givesmehope.com/
>
>   From:       Bonji                                  
>                                              
>
>   To:         "jQuery (English)"                  
>                                              
>
>   Date:       01/20/2010 11:46 AM                                             
>                                              
>
>   Subject:    [jQuery] Call ajax on sucess response from a previous ajax      
>                                               
>
> Hi.
>
> Im not sure if this is the correct way of going about this so i
> thought i'd ask the experts...
>
> I have a jquery ajax script which simply returns true or false based
> on the response from a php script.
>
> This works just fine.
>
> However i want to know if it is possible to load a second ajax call if
> the first returns true?
>
> I've tried placing the second $.ajax inside the success fuction of the
> first $.ajax but the second call never triggers or doesn't return
> anything.
>
> Is there a way of queuing $.ajax functions so they fire on after
> another?
>
>  graycol.gif
> < 1KViewDownload
>
>  ecblank.gif
> < 1KViewDownload


[jQuery] Re: jQuery Corner Help

2010-01-20 Thread Bonji
Hi

So you should have some thing like this for the div

div content

and something like this for the corner control.


 $(document).ready(function() {
  $(".rounder").corner("45px");
 });


also jquery.js
and jquery.corners.js in the head

You shouldn't need this part .corner("rounder 45px"); rather
use .corner("45px"); as i believe the default action is to simply
round the corners anyway. I use it this way and it works fine.

If this doesn't work you can try rounding each corner separately like
this

$(".rounder").corner("tr 45px").corner("tl 45px").corner("bl
45px").corner("br 45px");

If you have no luck with either of these id try changing the 45px to
something similar but smaller (43px for example).

This plugin i've found to be a bit glitchy with some corner sizes. I
had to change my corners from 5px to 3px just to make the corners
render smoothly.

And that problem occurred after using it with another plugin called
livequery.

So your problem could be caused by another plugin or some other factor
on the page.

I'd test this on a separate blank page to to make sure you know you
have the code correctly implemented then import it to the required
page and debug from there if required.

Hope this helps a bit, Ben


On Jan 20, 3:25 pm, mcrus  wrote:
> Hello,
>
> Completely new to jQuery. I am trying to use the corners. I have it
> only half working and sure there is something simple I am missing.
> When I implement a corner on a div. It is only applying to the top
> corners. I have tried adding "br" to the code, but it does not show
> up. Here is the way I have it in my code. This below will only round
> the top corners in my browser.
>
> Any suggestions would be greatly appreciated.
>
> Russ
>
> 
>  script>
>
>