[jQuery] Re: ajaxError, global vs local event

2009-03-04 Thread .png

I ended up setting up a local ajaxError callback that puts the
"textStatus" property to the settings object:

'error': function(request, textStatus) { this.textStatus =
textStatus; },

this way allows me to use that property into the global ajaxError
callback.

I will investigate further on this issue (and decide if this is an
issue in first place :D)

Ciao!

On 4 Mar, 15:58, ".png"  wrote:
> Hi everybody,
>   while I was writing my heavy-ajax-loaded app I noticed that while I
> can subscribe to localajaxErrorevents simply by specifing this
> within my $.ajax() settings object:
> 'error': function (XMLHttpRequest, textStatus, errorThrown) {
>   // typically only one of textStatus or errorThrown
>   // will have info
>   this; // the options for this ajax request}
>
> (http://docs.jquery.com/Ajax/jQuery.ajax#options)
>
> I can't do quite the same with a globalajaxError, altought the
> documentation says:
>
> ajaxError(Global Event)
> This global event behaves the same as the local error event.
> (http://docs.jquery.com/Ajax_Events)
>
> but:
> function (event, XMLHttpRequest, ajaxOptions, thrownError) {
>   // thrownError only passed if an error was caught
>   this; // dom element listening}
>
> (http://docs.jquery.com/Ajax/ajaxError#callback)
> Please notice the different parameters between local and global event.
>
> My problem is I relied on textStatus that's missing from the global
> event callback's parameters to catch json parser errors:
> if (textStatus == 'parsererror') alert('Gotta problem');
>
> I can't find anything on this group referring to this problem; have
> you ever run into this?


[jQuery] Re: OnMouseDown = create draggable, OnMouseUp = create droppable

2009-03-04 Thread delphilynx

Anyone that can read it and point me to the right direction?


[jQuery] Re: How to use anchor text as title attribute?

2009-03-04 Thread Klaus Hartl

> $('a').attr('title' , function() { $(this).text() } );
>
> I must be missing something simple here.

Yes, a return statement.

$('a').attr('title' , function() { return $(this).text(); });


--Klaus


[jQuery] [autocomplete]Error: $("#suggest1").autocomplete is not a function

2009-03-04 Thread efet


$().ready(function() {

  var data = [ {QUERY: $("#QUERY").val(), url:'test.asp?
Process=CheckCustomer'} ];
  $("#suggest1").autocomplete(data);

});


Test...



Data needs to be taken as:
test.asp?Process=CheckCustomer&QUERY=a

Not very familiary with jquery yet. Can anyone tell me why I get the
following error.

Error: $("#suggest1").autocomplete is not a function
Source File: 
http://www.refinethetaste.com/html/cp/default.asp?Section=orders&Process=AddOrder
Line: 162


[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread David Muir
$.ajax doesn't return the response, and can't because AJAX is 
asyncronous. That's why you've got callbacks that execute once you've 
got a response.


for what you're doing, just use:

$.post("/goods/detail/","id="+id, function(json){
   //do something useful with the data
   updateGoodsDetails(json);
}, 'json');

or:
$.post("/goods/detail/","id="+id, updateGoodsDetails, 'json');

David


Charles Liu wrote:

try to track down the json data,so you can:
1.alert(data); before return (if it doesn't work see the following)
2.change the POST method to GET from the server side and then input 
all paras into browser and see what will you get.(if it doesn't work 
see the following)

3.track down something from the server side script

2009/3/5 Adwin Wijaya >



nope, i want  to return as json.

price was there because i was logging into console. just for
debugging :) and i will do the calculation after it return the value.

I tried using async:false

and the result still undefined

function getGoodsDetail(id){
   $.ajax({
   type: "POST",
   url : "/goods/detail/",
   data : "id="+id,
   dataType: "json",
   async:false,
   success : function(data){
   return data ;
   }
   });
}

var x = getGoodsDetail(10);

any idea ?
 I think i need to have callback so that I can return the value ...
just like in $.post and $.get.

is it possible ?
thanks




On Mar 5, 9:06 am, James mailto:james.gp@gmail.com>> wrote:
> But does it work with async set to false?
> The code should work correctly if you have async set to false.
> However, you cannot do this (return the JSON from the function)
> properly without that setting set to false.
>
> By the way, is it suppose to be:
> result = price;
> ? I don't see what you're doing with the price variable in there.
>
> On Mar 4, 3:43 pm, Charles Liu mailto:charles.li...@gmail.com>> wrote:
>
> > hi Adwin,
> > it is "undefined" because it runs before ajax is finished.
> > maybe you should try to move "return result" next to the
position of "result
> > = data"
>
> > let me know if it works
>
> > Charles
>
> > 2009/3/5 Adwin Wijaya mailto:adwin.wij...@gmail.com>>
>
> > > Hi,
>
> > > can i have callback function on the $.ajax ?
> > > I don't want to use async since it will block the browser
... so can i
> > > use callback instead ?
>
> > > I would like to have function that return json like this
>
> > > function getGoodsDetail(id,member){
> > >   var result ;
> > >   $.ajax({
> > >type: "POST",
> > >url : "/goods/detail/",
> > >data : "id="+id,
> > >dataType: "json",
> > >async:false,
> > >success : function(data){
> > >var price = 0 ;
> > >if(member == 'Y'){
> > > price = data.priceMember ;
> > >}else{
> > >price = data.priceNonMember;
> > >}
> > >// I want to return data to user
> > >result = data
> > >}
> > >});
> > > return result; // --> always undefined
> > > }
>
> > > so when I call getGoodsDetail(id, membership) it will return
json
> > > value ...






[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread Charles Liu
try to track down the json data,so you can:
1.alert(data); before return (if it doesn't work see the following)
2.change the POST method to GET from the server side and then input all
paras into browser and see what will you get.(if it doesn't work see the
following)
3.track down something from the server side script

2009/3/5 Adwin Wijaya 

>
> nope, i want  to return as json.
>
> price was there because i was logging into console. just for
> debugging :) and i will do the calculation after it return the value.
>
> I tried using async:false
>
> and the result still undefined
>
> function getGoodsDetail(id){
> $.ajax({
>type: "POST",
>url : "/goods/detail/",
>data : "id="+id,
>dataType: "json",
>async:false,
>success : function(data){
> return data ;
>}
>});
> }
>
> var x = getGoodsDetail(10);
>
> any idea ?
>  I think i need to have callback so that I can return the value ...
> just like in $.post and $.get.
>
> is it possible ?
> thanks
>
>
>
>
> On Mar 5, 9:06 am, James  wrote:
> > But does it work with async set to false?
> > The code should work correctly if you have async set to false.
> > However, you cannot do this (return the JSON from the function)
> > properly without that setting set to false.
> >
> > By the way, is it suppose to be:
> > result = price;
> > ? I don't see what you're doing with the price variable in there.
> >
> > On Mar 4, 3:43 pm, Charles Liu  wrote:
> >
> > > hi Adwin,
> > > it is "undefined" because it runs before ajax is finished.
> > > maybe you should try to move "return result" next to the position of
> "result
> > > = data"
> >
> > > let me know if it works
> >
> > > Charles
> >
> > > 2009/3/5 Adwin Wijaya 
> >
> > > > Hi,
> >
> > > > can i have callback function on the $.ajax ?
> > > > I don't want to use async since it will block the browser ... so can
> i
> > > > use callback instead ?
> >
> > > > I would like to have function that return json like this
> >
> > > > function getGoodsDetail(id,member){
> > > >   var result ;
> > > >   $.ajax({
> > > >type: "POST",
> > > >url : "/goods/detail/",
> > > >data : "id="+id,
> > > >dataType: "json",
> > > >async:false,
> > > >success : function(data){
> > > >var price = 0 ;
> > > >if(member == 'Y'){
> > > > price = data.priceMember ;
> > > >}else{
> > > >price = data.priceNonMember;
> > > >}
> > > >// I want to return data to user
> > > >result = data
> > > >}
> > > >});
> > > > return result; // --> always undefined
> > > > }
> >
> > > > so when I call getGoodsDetail(id, membership) it will return json
> > > > value ...
>


[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread David Muir


Because you're returning your data to $.ajax, which isn't expecting 
anything to be returned from the callback.

Just use the success callback to do what you want with the result.

David

Adwin Wijaya wrote:

nope, i want  to return as json.

price was there because i was logging into console. just for
debugging :) and i will do the calculation after it return the value.

I tried using async:false

and the result still undefined

function getGoodsDetail(id){
$.ajax({
type: "POST",
url : "/goods/detail/",
data : "id="+id,
dataType: "json",
async:false,
success : function(data){
return data ;
}
});
}

var x = getGoodsDetail(10);

any idea ?
 I think i need to have callback so that I can return the value ...
just like in $.post and $.get.

is it possible ?
thanks




On Mar 5, 9:06 am, James  wrote:
  

But does it work with async set to false?
The code should work correctly if you have async set to false.
However, you cannot do this (return the JSON from the function)
properly without that setting set to false.

By the way, is it suppose to be:
result = price;
? I don't see what you're doing with the price variable in there.

On Mar 4, 3:43 pm, Charles Liu  wrote:



hi Adwin,
it is "undefined" because it runs before ajax is finished.
maybe you should try to move "return result" next to the position of "result
= data"
  
let me know if it works
  
Charles
  
2009/3/5 Adwin Wijaya 
  

Hi,

can i have callback function on the $.ajax ?

I don't want to use async since it will block the browser ... so can i
use callback instead ?

I would like to have function that return json like this

function getGoodsDetail(id,member){

  var result ;
  $.ajax({
   type: "POST",
   url : "/goods/detail/",
   data : "id="+id,
   dataType: "json",
   async:false,
   success : function(data){
   var price = 0 ;
   if(member == 'Y'){
price = data.priceMember ;
   }else{
   price = data.priceNonMember;
   }
   // I want to return data to user
   result = data
   }
   });
return result; // --> always undefined
}

so when I call getGoodsDetail(id, membership) it will return json

value ...





[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread Adwin Wijaya

nope, i want  to return as json.

price was there because i was logging into console. just for
debugging :) and i will do the calculation after it return the value.

I tried using async:false

and the result still undefined

function getGoodsDetail(id){
$.ajax({
type: "POST",
url : "/goods/detail/",
data : "id="+id,
dataType: "json",
async:false,
success : function(data){
return data ;
}
});
}

var x = getGoodsDetail(10);

any idea ?
 I think i need to have callback so that I can return the value ...
just like in $.post and $.get.

is it possible ?
thanks




On Mar 5, 9:06 am, James  wrote:
> But does it work with async set to false?
> The code should work correctly if you have async set to false.
> However, you cannot do this (return the JSON from the function)
> properly without that setting set to false.
>
> By the way, is it suppose to be:
> result = price;
> ? I don't see what you're doing with the price variable in there.
>
> On Mar 4, 3:43 pm, Charles Liu  wrote:
>
> > hi Adwin,
> > it is "undefined" because it runs before ajax is finished.
> > maybe you should try to move "return result" next to the position of "result
> > = data"
>
> > let me know if it works
>
> > Charles
>
> > 2009/3/5 Adwin Wijaya 
>
> > > Hi,
>
> > > can i have callback function on the $.ajax ?
> > > I don't want to use async since it will block the browser ... so can i
> > > use callback instead ?
>
> > > I would like to have function that return json like this
>
> > > function getGoodsDetail(id,member){
> > >   var result ;
> > >   $.ajax({
> > >        type: "POST",
> > >        url : "/goods/detail/",
> > >        data : "id="+id,
> > >        dataType: "json",
> > >        async:false,
> > >        success : function(data){
> > >            var price = 0 ;
> > >            if(member == 'Y'){
> > >                 price = data.priceMember ;
> > >            }else{
> > >                price = data.priceNonMember;
> > >            }
> > >            // I want to return data to user
> > >            result = data
> > >        }
> > >    });
> > > return result; // --> always undefined
> > > }
>
> > > so when I call getGoodsDetail(id, membership) it will return json
> > > value ...


[jQuery] Re: missing ; before statement

2009-03-04 Thread brian
$("#toc").change (function () {

There's a space after "change". Maybe that's it?

On Wed, Mar 4, 2009 at 8:36 PM, sanguisdex  wrote:
>
> I worked and begged on IRC all do to get this code:
>
> 
>        $(document).ready(function(){
>                $.fn.addTocHandler = function ( ) {
>                        $("#toc").change (function () {
>                                
> $("#book").load("/beta/catalog/extras/class_data.php?
> products_id=1&chapter_id=" + $(this).val(), function(){
>                                        $(this).addTocHandler().fadeIn();
>                                });
>                        });
>                        return this;
>                        });
>                if(undefined===window.chapterList){
>                        window.chapterList = ['toc'];
>                 }
>
>                $("#book").load("/beta/catalog/extras/class_data.php?
> products_id=1&chapter_id=" + chapterList +"", function(){
>                        $(this).addTocHandler();
>                });
>        });
> 
> bur when I ran it I got a the above error.  I cant see (and honestly
> an not that clear on) any errors made.
>
> Could some one point me in the right direction.
>
> JOsh
>


[jQuery] Re: missing ; before statement

2009-03-04 Thread Michael Geary

JOsh, do you have an editor that checks JavaScript syntax in real time? That
makes it much easier to track down problems like this. If you don't have
one, go here and get Komodo Edit:

http://www.activestate.com/komodo_edit/

Load your script into Komodo Edit and you should see a squiggly red
underline where the error is. Do you see where it's on the line after the
"return this;"?

Now you can experiment with that line and see if you can get the squiggly
underline to go away. First, put the cursor on the } character and note the
{ that gets highlighted with it. It's the one on the "fn.addTocHandler =
function() {" line, right? That looks good, but is the indentation right?
Looks like the "});" line should be indented one less tab.

That isn't the syntax error, of course, but it will help make it easier to
spot.

The "}" is matched with an opening "{", but what does the ")" on that line
match with? Anything? What happens if you remove that character?

-Mike

> From: sanguisdex
> 
> I worked and begged on IRC all do to get this code:
> 
> 
>   $(document).ready(function(){
>   $.fn.addTocHandler = function ( ) {
>   $("#toc").change (function () {
>   
> $("#book").load("/beta/catalog/extras/class_data.php?
> products_id=1&chapter_id=" + $(this).val(), function(){
>   
> $(this).addTocHandler().fadeIn();
>   });
>   });
>   return this;
>   });
>   if(undefined===window.chapterList){
>   window.chapterList = ['toc'];
>}
> 
>   $("#book").load("/beta/catalog/extras/class_data.php?
> products_id=1&chapter_id=" + chapterList +"", function(){
>   $(this).addTocHandler();
>   });
>   });
> 
> bur when I ran it I got a the above error.  I cant see (and 
> honestly an not that clear on) any errors made.
> 
> Could some one point me in the right direction.
> 
> JOsh
> 



[jQuery] Re: jquery .data() not sure if I'm using this properly

2009-03-04 Thread James

You're setting the data on ul#otherLogin, but you're retrieving it on
div#otherLogin.

On Mar 4, 4:53 pm, pedalpete  wrote:
> I'm trying to figure out how to set and retrieve data without putting
> it into a class, element, or anything else visible, and in the dom.
>
> My site is integrating Facebook connect, and sometimes if a user
> hasn't logged in, I bring them to the login, but I'm trying to
> remember what function would have run if they were logged in so that I
> can call that after they login.
> currently i set the data like this
> [code]
> jQuery('ul#otherLogin').data('selectForLogin','getTracked');
> [/code]
> i then later try to get the value for 'selectForLogin like this
> [code]
>   var refreshWhat=jQuery('div#otherLogin').data('selectForLogin');
> [/code]
>
> but i always get 'undefined';
>
> i've looked at the documentationhttp://docs.jquery.com/Data,
> but it leaves me with two questions
> 1) why is my data being set
> 2) do i have to 'remove' a data value? or do they just get overwritten
> if I set it again?
>
> any ideas?


[jQuery] Re: [jQuery Sifr Plugin]

2009-03-04 Thread MauiMan2

I too couldn't get it to work with 1.3.


[jQuery] jquery .data() not sure if I'm using this properly

2009-03-04 Thread pedalpete

I'm trying to figure out how to set and retrieve data without putting
it into a class, element, or anything else visible, and in the dom.

My site is integrating Facebook connect, and sometimes if a user
hasn't logged in, I bring them to the login, but I'm trying to
remember what function would have run if they were logged in so that I
can call that after they login.
currently i set the data like this
[code]
jQuery('ul#otherLogin').data('selectForLogin','getTracked');
[/code]
i then later try to get the value for 'selectForLogin like this
[code]
  var refreshWhat=jQuery('div#otherLogin').data('selectForLogin');
[/code]

but i always get 'undefined';

i've looked at the documentation http://docs.jquery.com/Data,
but it leaves me with two questions
1) why is my data being set
2) do i have to 'remove' a data value? or do they just get overwritten
if I set it again?

any ideas?


[jQuery] Re: html data in IE

2009-03-04 Thread pedalpete

I can't display the 'issue' as i've rewritten the page to get rid of
the errors.
I'm just not sure if the way I have gone about fixing it is a bad
move.



On Mar 4, 10:29 am, James  wrote:
> Can you put up a demo page that displays this issue?
>
> On Mar 3, 6:15 pm,pedalpete wrote:
>
> > I've been struggling with IE for a few days now, and looking through
> > the HTML check in debugbar, it shows that IE would throw an error on
> > every .html(''), so I took any place where I had the
> > html defined within the html(). I put the html into a javascript
> > variable, and then it told me that the closing / was an invalid
> > character. So I commented those out with \/.
>
> > My question is, should I have done this?
> > I can still back out of it, though it doesn't appear to be causing any
> > problems in any of the browsers.


[jQuery] missing ; before statement

2009-03-04 Thread sanguisdex

I worked and begged on IRC all do to get this code:


$(document).ready(function(){
$.fn.addTocHandler = function ( ) {
$("#toc").change (function () {

$("#book").load("/beta/catalog/extras/class_data.php?
products_id=1&chapter_id=" + $(this).val(), function(){
$(this).addTocHandler().fadeIn();
});
});
return this;
});
if(undefined===window.chapterList){
window.chapterList = ['toc'];
 }

$("#book").load("/beta/catalog/extras/class_data.php?
products_id=1&chapter_id=" + chapterList +"", function(){
$(this).addTocHandler();
});
});

bur when I ran it I got a the above error.  I cant see (and honestly
an not that clear on) any errors made.

Could some one point me in the right direction.

JOsh


[jQuery] Javascript search library

2009-03-04 Thread Khai

I have a collection of DIVs (or a JSON array).  Is there a javascript
library that can search through a JSON array and return a collection
of matched elements, and support advanced search with boolean
operator?

Thanks
Khai


[jQuery] Re: Exception errors when using validation rules

2009-03-04 Thread wwor...@gmail.com
problem solved

Jörn has a new version 1.5.1 of jquery.validate.js

So for anyone who stumbles upon this you CANNOT run

jquery.validate.js
$Id: jquery.validate.js 5952 2008-11-25 19:12:30Z

with
jQuery 1.2.6
$Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
$Rev: 5685 $

you MUST upgrade to the following
jquery.validate.js
$Id: jquery.validate.js 6096 2009-01-12 14:12:04Z

with jquery 1.3.1
Date: 2009-01-21 20:42:16 -0500 (Wed, 21 Jan 2009)
Revision: 6158

On Mar 4, 1:14 pm, James  wrote:
> The part:
> [Exception... "'Syntax error, unrecognized expression:
> [...@for='license']' when calling method:
>
> tells you that somewhere in your code you have the expression
> [...@for='license']' that is unrecognized.
> Remove the @ sign as that is no longer valid from jQuery 1.3.
> Make sure you have the latest version of Validate plug-in also that
> supports jQuery 1.3.
>
> On Mar 3, 7:17 pm, "wwor...@gmail.com"  wrote:
>
>
>
> > Hi everyone, i'm getting a weird exception with 1.3.1 please see the
> > video link to watch what happens.
>
> >http://screencast.com/t/4Ih9rhKwZP
>
> > and if you don't watch the video i'm doing an ajax submit but it's
> > refreshing the page and throwing the error
>
> > exception:
> > [Exception... "'Syntax error, unrecognized expression:
> > [...@for='license']' when calling method:
> > [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e
> > (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]
>
> > jquery
> >         var container = $('div.container');
> >         $('#addlicense').validate({
> >                         submitHandler: function() {
> >                                 $.ajax({
> >                                   type: 'POST',
> >                                   url: 'process.php?cmd=addlicense',
> >                                   dataType: 'html',
> >                                   data: { issuedby: $('#issuedby').val(), 
> > license: $
> > ('#license').val(), licensenum: $('#licensenum').val(), issueddate: $
> > ('#issueddate').val(), expiredate: $('#expiredate').val(), licenseid: $
> > ('#licenseid').val(), action: $('#action').val(), noexpire: $("input
> > [name='noexpire']:checked").val() },
> >                                   success: function(data){
> >                                     $('#licenseresult').prepend(data);
> >                                   },
> >                                   error: function(){
> >                                     alert("An error has occurred. Please 
> > try again.");
> >                                   },
> >                                   complete: function() {
> >                                     $('#results').fadeIn('slow');
> >                                     $('#licensenew').colorBlend([{ 
> > fromColor: '#F3F3F3', toColor:
> > '#33CC33', param: 'backgroundColor', cycles: 1 }]);
> >                                     $("#addlicense").slideUp();
> >                                     $("#nolicense").hide();
> >                                     $("#licensectr").show();
> >                                   }
> >                                 });
> >                                 return false;
> >                         },
> >                         errorContainer: container,
> >                         errorLabelContainer: $("ul", container),
> >                         wrapper: 'li',
> >                         meta: "validate",
> >                         rules: {
> >                                 license: {
> >                                         required: true
> >                                 },
> >                                 licensenum: {
> >                                         required: true
> >                                 },
> >                                 issuedby: {
> >                                         required: true
> >                                 },
> >                                 issueddate: {
> >                                         required: true
> >                                 },
> >                                 expiredate: {
> >                                         required: {
> >                                                 required: true,
> >                                                 depends: function(element) {
> >                                                         return 
> > $("#noexpire:checked")
> >                                                 }
> >                                         }
> >                                 }
> >                         },
> >                         messages: {
> >                                 license: {
> >                                         required: "License Name Description 
> > is required"
> >                                 },
> >                                 licensenum: {
> >                                         required: "License number ID is 
> > required"
> >                                 },
> >                   

[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread James

But does it work with async set to false?
The code should work correctly if you have async set to false.
However, you cannot do this (return the JSON from the function)
properly without that setting set to false.

By the way, is it suppose to be:
result = price;
? I don't see what you're doing with the price variable in there.

On Mar 4, 3:43 pm, Charles Liu  wrote:
> hi Adwin,
> it is "undefined" because it runs before ajax is finished.
> maybe you should try to move "return result" next to the position of "result
> = data"
>
> let me know if it works
>
> Charles
>
> 2009/3/5 Adwin Wijaya 
>
>
>
> > Hi,
>
> > can i have callback function on the $.ajax ?
> > I don't want to use async since it will block the browser ... so can i
> > use callback instead ?
>
> > I would like to have function that return json like this
>
> > function getGoodsDetail(id,member){
> >   var result ;
> >   $.ajax({
> >        type: "POST",
> >        url : "/goods/detail/",
> >        data : "id="+id,
> >        dataType: "json",
> >        async:false,
> >        success : function(data){
> >            var price = 0 ;
> >            if(member == 'Y'){
> >                 price = data.priceMember ;
> >            }else{
> >                price = data.priceNonMember;
> >            }
> >            // I want to return data to user
> >            result = data
> >        }
> >    });
> > return result; // --> always undefined
> > }
>
> > so when I call getGoodsDetail(id, membership) it will return json
> > value ...
>
>


[jQuery] Re: how to add callback in the $.ajax ?

2009-03-04 Thread Charles Liu
hi Adwin,
it is "undefined" because it runs before ajax is finished.
maybe you should try to move "return result" next to the position of "result
= data"

let me know if it works

Charles

2009/3/5 Adwin Wijaya 

>
> Hi,
>
> can i have callback function on the $.ajax ?
> I don't want to use async since it will block the browser ... so can i
> use callback instead ?
>
> I would like to have function that return json like this
>
> function getGoodsDetail(id,member){
>   var result ;
>   $.ajax({
>type: "POST",
>url : "/goods/detail/",
>data : "id="+id,
>dataType: "json",
>async:false,
>success : function(data){
>var price = 0 ;
>if(member == 'Y'){
> price = data.priceMember ;
>}else{
>price = data.priceNonMember;
>}
>// I want to return data to user
>result = data
>}
>});
> return result; // --> always undefined
> }
>
> so when I call getGoodsDetail(id, membership) it will return json
> value ...
>


[jQuery] how to add callback in the $.ajax ?

2009-03-04 Thread Adwin Wijaya

Hi,

can i have callback function on the $.ajax ?
I don't want to use async since it will block the browser ... so can i
use callback instead ?

I would like to have function that return json like this

function getGoodsDetail(id,member){
   var result ;
   $.ajax({
type: "POST",
url : "/goods/detail/",
data : "id="+id,
dataType: "json",
async:false,
success : function(data){
var price = 0 ;
if(member == 'Y'){
 price = data.priceMember ;
}else{
price = data.priceNonMember;
}
// I want to return data to user
result = data
}
});
return result; // --> always undefined
}

so when I call getGoodsDetail(id, membership) it will return json
value ...


[jQuery] jquery validation with added method

2009-03-04 Thread dailo

i've added this to the top of my page

jQuery.validator.addMethod("pCode", function(value) { // Addon method
for validating postal codes. Valid formats are (X1X 1X1) or (X1X1X1)
or (X1X-1X1).
return value.match(/^[a-zA-Z][0-9][a-zA-Z](-| 
)?[0-9][a-zA-Z]
[0-9]$/);

}, 'Please enter a valid postal code');


pCode works great. But when I try to put a conditional statement like
this:

$(myself).find("form").validate({


rules: {
postalCode: {
pCode: 
function(element) {

alert($(myself).find("select[name=countryId]").val() !=
'800');

return ($(myself).find("select[name=countryId]").val() !=
'800' );
  }

}



}

the condition doesn't take. It validates my postalCode field
regardless of what value is returned. the alert is even coming out as
"false" for me and its still validating this field. I've tried
hardcoding the function to "false" and it seems to work. Any ideas? I
know its probably something stupid that I forgot


[jQuery] Re: nothing working in ie

2009-03-04 Thread James

I've noticed you're using defer on all the scripts. Don't. Especially
not on jQuery related scripts. You should just remove the defer on all
of the script tags.

On Mar 4, 3:03 pm, James  wrote:
> In your script tag, try using defer="defer" instead of just defer. Or
> try just removing the defer altogether and see what happens.
>
> On Mar 4, 2:26 pm, annam  wrote:
>
> > tried it, didnt really find anything. also installed companion.js ,
> > which also found an error in my document.ready line..
> > so i removed all the code from within the document.ready function but
> > the error is still there!
>
> > this is the code i kept:
>
> > 
> > $(document).ready(function() {
>
> > });
>
> > 
>
> > the companion.js errors are:
>
> > Object expected         ($(document).ready(function() { line)
> > Syntax error               ( line)
>
> > and these are the jquery scripts i have embedded in the page.
> > everything is in the head, with the inline script under the embedded
> > ones
>
> >