[jQuery] Re: HttpHandler not returning JSON data

2008-12-27 Thread JQueryProgrammer

I got the solution to this. Actually this code was working in Firefox
and not in IE. When I tried to run in IE, it was giving error 12030
(Server unexpectedly terminated connection) from IE's XMLHttpRequest
object. The solution:

In my HttpHandler I included the code:

System.IO.Stream st = context.Request.InputStream;
byte[] buf = new byte[100];
while (true)
{
int iRead = st.Read(buf, 0, 100);
if (iRead == 0)
break;
}
st.Close();

Actually ASp.Net does not read the complete incoming input stream
automatically. In order for IE's XMLHttpRequest object to properly
read return stream the input stream must be completely read by the
server (even if you are not interested in it).

On Dec 28, 10:29 am, JQueryProgrammer  wrote:
> Hi All,
>
> I was working with a basic example where I wanted to get JSON data
> from the HttpHandler. My javascript code looks like:
>
> $.ajax({
>     url: 'Handler1.ashx',
>     type: 'POST',
>     data: { name: 'MyName' },
>     contextType: 'application/json; charset=utf-8',
>     dataType: 'json',
>     success: function(data) {
>         alert("Data Saved " + data.name);
>     }
>
> });
>
> My Handler1.ashx code looks like:
>
> context.Response.ContentType = "application/json";
> string results = "{ 'name': '"+ context.Request.Params["name"] +"' }";
> context.Response.Write(results);
>
> But I am not getting the results right. Infact I am not getting any
> result in data.name. Please let me know what is the mistake and what
> is the correct way to get JSON data.


[jQuery] Re: AJAX with IE and method POST

2008-12-27 Thread JQueryProgrammer

Thanks a ton George. You saved my day. I have been trying to getting
this issue and was searching for a solution. Your post helped.

On Nov 15, 1:29 am, George  wrote:
> No i did not...I did pass exactly this '{}' (empty JSON data).
>
> As i said the problem was that i were not reading the InputStream till
> the end cause i knew that data would be empty. And it messes up IE's
> XMLHttpRequest object so it can not read properly output from the
> server.
>
> George.
>
> On Nov 14, 2:22 pm, Mike Nichols  wrote:
>
> > did you forget to pass data (data:{}) in the ajax call? I have had
> > that trip me up when doing posts via ajax.
>
> > On Nov 14, 10:35 am, George  wrote:
>
> > > Hi guys/girls,
> > > I just wanted to post here my problems (and solution) I had been
> > > struggling with last 2 days.
>
> > > I was doing JQuery AJAX POST and it was not working in IE wile working
> > > in FireFox.
> > > Sometimes you will get12030error (Server unexpectedly terminated
> > > connection) from IE's XMLHttpRequest object.
>
> > > I discovered that in order for IE's XMLHttpRequest object to properly
> > > read return stream the input stream must be completely read by the
> > > server (even if you are not interested in it).
>
> > > Some frameworks do it automatically and some do not. For example
> > > ASP.NET does not do it automatically.
> > > I was trying to do POST to .ashx handler and was getting errors.
>
> > > So adding this code to my handler fixed the problem.
>
> > > System.IO.Stream st = context.Request.InputStream;
> > >         byte []buf = new byte[100];
> > >         while (true)
> > >         {
> > >             int iRead = st.Read(buf, 0, 100);
> > >             if( iRead == 0 )
> > >                 break;
> > >         }
> > >         st.Close();
>
> > > So I am just posing it for Google to spider it and people to be able
> > > to find it. Cause when I googled I found a lot of people having
> > > problem with12030error but no solution.
>
> > > Good luck,
> > > George- Hide quoted text -
>
> > - Show quoted text -


[jQuery] Re: file browser jQuery plugin?

2008-12-27 Thread Jack Killpatrick


This might do it for you:

http://abeautifulsite.net/notebook.php?article=58

- Jack

Girish Venkatachalam wrote:

Hello friends,

Is it possible to create a directory view with jQuery and Ajax?

I find a few plugins in repository but they use PHP and I cannot get
them to work.

I want a Perl or Python CGI script to generate the directory structure
and use jQuery to display it in the browser.

How to do it?

Thanks in advance for the help.

Happy holidays!

-Girish

  





[jQuery] HttpHandler not returning JSON data

2008-12-27 Thread JQueryProgrammer

Hi All,

I was working with a basic example where I wanted to get JSON data
from the HttpHandler. My javascript code looks like:

$.ajax({
url: 'Handler1.ashx',
type: 'POST',
data: { name: 'MyName' },
contextType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(data) {
alert("Data Saved " + data.name);
}
});

My Handler1.ashx code looks like:

context.Response.ContentType = "application/json";
string results = "{ 'name': '"+ context.Request.Params["name"] +"' }";
context.Response.Write(results);

But I am not getting the results right. Infact I am not getting any
result in data.name. Please let me know what is the mistake and what
is the correct way to get JSON data.


[jQuery] How do I cache

2008-12-27 Thread bob

I would like to have a registration form cached for 1 year public and
private.
How do i go about it.
Thats what I tried and register.html was not cached.

jq.ajax({
type: "POST",
url: "http://www.example.com/register.html";,
dataType: "html",
cache: true,

success: function(response) {}
});
=
content of register.html












[jQuery] Re: .ajaxSend fires six times

2008-12-27 Thread Daniel

should be $(document).ajaxSend(function(){...})

Cheers,
Daniel.

On Dec 28, 3:14 am, "Lay András"  wrote:
> Hello!
>
> On Sat, Dec 27, 2008 at 8:27 PM, Michael Geary  wrote:
> > Well, that's odd that it didn't work. Try a single element by ID then:
>
> > $('#someExistingID').ajaxSend(...);
>
> Trying, don't works. Here's my test page:
>
> http://bogex.hu/jquerytest.php


[jQuery] Re: Code not working in IE but is working in FF

2008-12-27 Thread Althalos

Nope, I'm sorry but that doesn't seem to work. Note that setting
opacity to zero works in both browsers.

On 28 Dec, 01:25, "Alexandre Plennevaux" 
wrote:
> really not sure, but maybe try
>
> A/
>
> 1- (step/1)  instead of 1-step/1
>
> B/
>
> $("#slogan").css('opacity',0);  instead of $("#slogan").css('opacity','0');
>
> On Sun, Dec 28, 2008 at 1:04 AM, Althalos  wrote:
>
> > I posted something similarly before but I posted wrong code. This
> > time, everything is correct and I'll provide all the information
> > needed.
>
> > First of all, the URL to the site which is not working is
> >http://uf.ekdahlproduction.com/itsvintage2/
>
> > The error: In FF everything works perfectly but in IE it gets stuck on
> > 1% and nothing happens whatsoever.
>
> > The code:
> > $(document).ready(function(){
> >    $("#slogan").css('opacity','0');
> >    var step = 1;
> >   (function(){
> >      step -= 100;
> >      $("#percentage").text(100-step/100 + '%');
> >      if ( step > 0 )
> >         $("#logo").fadeTo(100,1-step/1, arguments.callee);
> >         else window.location = "http://uf.ekdahlproduction.com/
> > itsvintage2/home.html";
> >      if ( step == 3500 )
> >        $("#slogan").fadeTo(3500,1);
> >   })();
>
> > });
>
> > Comments: I have noticed that it changes the opacity correctly, and
> > also sets the content of #percentage to 1%, therefore Jquery must be
> > working. Maybe this can be some kind of general javascript error?
> > Something that IE interprets differently than FF?
>
> > Thank you


[jQuery] Re: Code not working in IE but is working in FF

2008-12-27 Thread Alexandre Plennevaux

really not sure, but maybe try


A/

1- (step/1)  instead of 1-step/1


B/

$("#slogan").css('opacity',0);  instead of $("#slogan").css('opacity','0');


On Sun, Dec 28, 2008 at 1:04 AM, Althalos  wrote:
>
> I posted something similarly before but I posted wrong code. This
> time, everything is correct and I'll provide all the information
> needed.
>
> First of all, the URL to the site which is not working is
> http://uf.ekdahlproduction.com/itsvintage2/
>
> The error: In FF everything works perfectly but in IE it gets stuck on
> 1% and nothing happens whatsoever.
>
> The code:
> $(document).ready(function(){
>$("#slogan").css('opacity','0');
>var step = 1;
>   (function(){
>  step -= 100;
>  $("#percentage").text(100-step/100 + '%');
>  if ( step > 0 )
> $("#logo").fadeTo(100,1-step/1, arguments.callee);
> else window.location = "http://uf.ekdahlproduction.com/
> itsvintage2/home.html";
>  if ( step == 3500 )
>$("#slogan").fadeTo(3500,1);
>   })();
>
> });
>
> Comments: I have noticed that it changes the opacity correctly, and
> also sets the content of #percentage to 1%, therefore Jquery must be
> working. Maybe this can be some kind of general javascript error?
> Something that IE interprets differently than FF?
>
> Thank you


[jQuery] Code not working in IE but is working in FF

2008-12-27 Thread Althalos

I posted something similarly before but I posted wrong code. This
time, everything is correct and I'll provide all the information
needed.

First of all, the URL to the site which is not working is
http://uf.ekdahlproduction.com/itsvintage2/

The error: In FF everything works perfectly but in IE it gets stuck on
1% and nothing happens whatsoever.

The code:
$(document).ready(function(){
$("#slogan").css('opacity','0');
var step = 1;
   (function(){
  step -= 100;
  $("#percentage").text(100-step/100 + '%');
  if ( step > 0 )
 $("#logo").fadeTo(100,1-step/1, arguments.callee);
 else window.location = "http://uf.ekdahlproduction.com/
itsvintage2/home.html";
  if ( step == 3500 )
$("#slogan").fadeTo(3500,1);
   })();

});

Comments: I have noticed that it changes the opacity correctly, and
also sets the content of #percentage to 1%, therefore Jquery must be
working. Maybe this can be some kind of general javascript error?
Something that IE interprets differently than FF?

Thank you


[jQuery] [plugins] Form - Success function fires multiple x's

2008-12-27 Thread Up-Works

I am using the ajaxForm() to submit a form and the success function
that is defined in the options array is firing 3 times. Any ideas?

Code:

var options = {
target:'.updateStatus',
beforeSubmit:  updStatus,
success:   showResponse,
url:   'saveAdmin.php',
type:  'post'

};

$('.editProviderType').ajaxForm(options);

//updStatus Func()
function updStatus(formData, jqForm, options) {
$('form.editProviderType').slideUp();
var spanName = 'span#TypeName'+formData[3]['value'];
$(spanName).text(formData[0]['value']);

return true;
}


//showResponse funct()
function showResponse(responseText, statusText)  {

$('form.editProviderType').resetForm();

//uiMessage('success','Provider Type Edited Successfully');

console.log('success');

return true;

}


[jQuery] Re: Selecting disparate elements in unobtrusive javascript without parameters?

2008-12-27 Thread Klaus Hartl

> > That would work fine, but it involves parsing the ID for a name
> > component that is "common" to the link and the DIV.
>
> Yes, indeed, that is exactly what you would do. But it's so simple - it
> takes less code to do it than describe it. For example:
>
>     $(function() {
>         $('#left a').click( function() {
>             $( '#' + this.id.replace( '_link', '_div' ) ).doSomething();
>         });
>     });
>
> Or another way to do the same thing:
>
>     $(function() {
>         $('#left a').click( function() {
>             $( '#' + this.id.split('_')[0] + '_div' ).doSomething();
>         });
>     });
>
> Or if you have several related elements to operate on:
>
>     $(function() {
>         $('#left a').click( function() {
>             var base = '#' + this.id.replace( '_link', '_' );
>             $( base + 'div' ).doSomething();
>             $( base + 'navlink' ).doSomethingElse();
>             $( base + 'whatever' ).doWhatever();
>         });
>     });
>
> What's not to like?

One thing I can think of is that you need to rely on the id's being in
a certain format, e.g you're creating a dependency of client-side and
PHP code. (Re-)using the hash makes it agnostic of the format of the
id.

--Klaus


[jQuery] Re: .animate and border sides

2008-12-27 Thread Nikola

Thanks Ricardo, I forgot to link to UI in my minimal case but I do
have it included in the project I am working on so that wasn't the
problem.  I was, however, unaware of the "borderSideColor" color
animation.  Sometimes the answers can be right under ones nose.
Thanks much... now if I could just find my glasses. haha


[jQuery] Re: Permission denied to get property HTMLDivElement.parentNode

2008-12-27 Thread MorningZ

Can you provide a working sample to help others help you with your
issue?



On Dec 27, 3:20 pm, Marta Figueiredo  wrote:
> Hi,
> I have googled the mentioned exception and found out that it is thrown
> only on Firefox, which has already been reported as a FF problem.
> However.. is it preventing the correct execution of my application.
> Does anyone know of a way to prevent this message to be thrown?
> Thanks
> M.


[jQuery] Re: image tag xhtml validate

2008-12-27 Thread Ricardo Tomasi

If your document is XHTML, $('body').append('') will
give you a properly closed  tag, do you have an example where
that doesn't happen? All manipulation on jQuery's side happens via the
available DOM methods, from that point on the browser itself handles
creating/altering/moving of elements.

On Dec 26, 8:42 am, Saledan  wrote:
> Maybe i don't understand well.. but .. sure it's html anyway, and the
> browser render it without issue, but i mean that the tag closure in
> xhtml stardard is different and in this way you don't follow the
> standard..
>
> thank you
> Max
>
> On 26 Dic, 02:55, Klaus Hartl  wrote:
>
> > Well, as long as you serve your so called XHTML as text/html it is
> > HTML anyway, thus no need to worry about a thing.
>
> > --Klaus
>
> > On 25 Dez., 18:48, Saledan  wrote:
>
> > > Hi,
> > > just a question about xhtml validation.
> > > I have an xhtml page and it has been validate.
> > > Now i add with .append some image, i suppose that the img tag is in
> > > html and not xhtml ..  and not ... is there a
> > > solution to have all in xhtml format?
>
> > > thanks
> > > bye
> > > max


[jQuery] Permission denied to get property HTMLDivElement.parentNode

2008-12-27 Thread Marta Figueiredo


Hi,
I have googled the mentioned exception and found out that it is thrown 
only on Firefox, which has already been reported as a FF problem. 
However.. is it preventing the correct execution of my application.

Does anyone know of a way to prevent this message to be thrown?
Thanks
M.



[jQuery] Re: .animate and border sides

2008-12-27 Thread Ricardo Tomasi

You need to include jQuery UI (ui.jquery.com) to have these kind of
transitions available.

http://docs.jquery.com/UI/Effects/ColorAnimations

On Dec 27, 4:49 am, Nikola  wrote:
> Hello,
>
> I am trying to animate a color change for the top and right borders of
> an element.
>
> A) In Firefox the border size is animated but the color change is not
> on the first hover only.  After that the border color changes as
> though you were affecting it via a pseudo class in CSS.
>
> B) Behavior in IE7 varies.  In some cases animating a "borderSide"
> breaks the code altogether. In the minimal case I'm providing the top
> border changes color without animation and there is no effect on the
> right border.
>
> It would be great to be able to animate individual border sides.  In
> addition it would be great to control what aspect of the border we
> wish to animate, just the size, size and color, just the color etc..
> Animating individual border colors can be very useful...
>
> MINIMAL TEST CASE:  http://paste.pocoo.org/show/96878/
>
> Thanks,
> Nikola


[jQuery] Re: .ajaxSend fires six times

2008-12-27 Thread Lay András

Hello!

On Sat, Dec 27, 2008 at 8:27 PM, Michael Geary  wrote:

> Well, that's odd that it didn't work. Try a single element by ID then:
>
> $('#someExistingID').ajaxSend(...);

Trying, don't works. Here's my test page:

http://bogex.hu/jquerytest.php


[jQuery] Re: Undocumented move/copy behavior of append() et al.

2008-12-27 Thread Ricardo Tomasi

How about something like "If there is more than a single target (the
element to which X will be appended), the source element(s) will be
cloned, and the original(s) will remain in place. Otherwise the source
element is moved." I don't feel like editing the wiki, my english can
be quite confusing.

- ricardo

On Dec 27, 2:29 pm, "Markus Gritsch"  wrote:
> On Sat, Dec 27, 2008 at 6:40 AM, Dave Methvin  wrote:
>
> > Well, like I said back then, jQuery *must* append clones of the nodes
> > in the case where you are appending to multiple targets.
>
> Agreed.
>
> > That only
> > leaves a question about the one-target-node case. If the default was
> > to append a clone in that situation, it wouldn't be possible to select
> > nodes and move it to a new location in the DOM tree!
>
> IMO it would have been possible by using a 'moveIfSingleTarget'
> boolean-parameter for example or something the like.  This way the
> intended behavior would be seen clearly.
>
> The current danger lies in the silent semantic change depending on the
> target set count.  Currently it is not obvious that one has to put a
> .clone() into the chain to protect the original node from being moved
> if the target set happens to contain just one element, whereas the
> code without the .clone() works perfectly for cases where more than
> one elment matches the selector.
>
> >> At least the current behaviour should be explicitly mentioned in
> >> the API documentation.
>
> > That would be a good idea. Basically all the methods that insert
> > elements documented here are affected:
>
> >http://docs.jquery.com/Manipulation
>
> > So would the best thing to do be to have some single page that
> > describes the behavior, and reference it on that page?
>
> Probably.  This quirk should explicitly be documented, because (at
> least to me) it feels quite strange.
>
> Kind regards,
> Markus


[jQuery] Re: script behaves different in IE than in Firefox

2008-12-27 Thread Ricardo Tomasi

What exactly doesn't work on FF? From what I see, you're not using the
value returned from the GET anywhere. When you click a link, it sends
the GET immediately and then returns true, which causes the link to be
followed. My guess is that IE finishes the Ajax request before going
on to the href, while FF just aborts the request and goes straight to
it. If that's the case, you could delay the click until the GET has
been processed:

$('a').click(function(){

  var tp = this.id.charAt(0),
   itemid = this.id.substr(1),
   link = $(this).attr('href');

  if ( tp && tp != 'l' && tp != 'c' && this.id.length >= 2 &&
itemid.chartAt(0) >= 1 && !itemid.match(/\D/) ) {
  var h = Math.random();
  $.get("/click-count.php", { id:itemid, type:tp, h:h }, function()
{ window.location = link; });
  return false;
 }

});

in this case 'return true' is unneeded as it does nothing, when the ID
doesnt fit the criteria. If it does, then we return false to cancel
the click and change the location to the link only after the AJAX call
is returned. Be aware that in case the GET fails all anchors on the
page will stop working, that can be avoided by using $.ajax instead
and setting the error callback to follow the href also.

cheers,
- ricardo
On Dec 27, 1:55 pm, lapinkulta  wrote:
> Now i get your point. However, it must be also a jquery issue
> as the script and click-count.php works fine in IE.
>
> I also think there are no overlapping requests, as the script
> is fired only once when a "a" is clicked.
>
> Still wondering what could be wrong...


[jQuery] Re: question

2008-12-27 Thread Dirceu Barquette
Hi Mike,

*Yes, of course I'd be delighted to have you mention my name - and even more
so if you can link it to my blog at http://mg.to/. :-)*
You can be shure ;-)

*BTW, you may want to take a look at Google Code as an alternative to
SourceForge.*
I'm a GNU/Linux instructor and sourceforge has made a good job to free
software. It's important give my acknowledgement and I don't think about
disadvantages. You know?

Keep in touch!

Dirceu Barquette

2008/12/27 Michael Geary 

>  Hi Dirceu,
>
> I'm glad that was helpful.
>
> Yes, of course I'd be delighted to have you mention my name - and even more
> so if you can link it to my blog at http://mg.to/. :-)
>
> BTW, you may want to take a look at Google Code as an alternative to
> SourceForge. Each one has some advantages and disadvantages, but it's nice
> to have a couple of options.
>
> -Mike
>
>  --
> *From:* Dirceu Barquette
> Hi Mike,
>
> Fantastic!!! This is very very good!!!
> I'll publish this CMS at sourceforge soon, and if you agree your name will
> be appear in special thanks. Ok? This is the most important contribution
> form my project.
> Thank you very much!
>
> Dirceu Barquette
>
> 2008/12/24 Michael Geary
>
>>  I must have been getting forgetful when I posted that suggestion. As I
>> mentioned, .toSource() is not available in all browsers, so it wouldn't be
>> suitable for your CMS feature that you want to make available to your site's
>> visitors.
>>
>> But .toString() *is* available in all browsers, and it gives you the
>> source code for a function. So you can just use that instead.
>>
>> Here's a test case:
>>
>> http://mg.to/test/jquery-methods.html
>>
>> That page lists all of the jQuery and jQuery() methods in alphabetical
>> order.
>>
>> The code is:
>>
>> jQuery(function() {
>> dump( 'jQuery', jQuery );
>> dump( 'jQuery()', jQuery.prototype );
>>
>> function dump( title, object ) {
>> var list = [];
>> for( name in object ) {
>> var fn = object[name];
>> if( jQuery.isFunction(fn) ) {
>> list.push( '' + title + '.' + name + 
>> fn.toString().match(/(\([^)]*\))/)[1] + '' );
>>
>> }
>> }
>> $('#list').append( '' + title + ' methods:' + 
>> list.sort().join('') );
>> }
>> });
>>
>> -Mike
>>
>


[jQuery] Re: Looking for an automated image replace loop

2008-12-27 Thread BarisArt

Hi Kean!

Thanks for this. it is working!
You made my weekend :)

Baris


On 16 dec, 00:39, Kean  wrote:
> I forgot to include the detection script to see if it's the last child
>
>     var cur = $("#gallery li:visible");
>   if (cur.is(":last-child") ) {
>       cur.fadeOut(500, function(){
>       // run the loop function again when time is up, in this case 5
> seconds
>       $("#gallery li:first-child").fadeIn(500, setTimeout(loop,
> 5000));
>     });
>
>   }
>
> else {
>     cur.fadeOut(500, function(){
>       // run the loop function again when time is up, in this case 5
> seconds
>       cur.next().fadeIn(500, setTimeout(loop, 5000));
>     });
>
> }
>
> On Dec 15, 3:32 pm, Kean  wrote:
>
>
>
> > This might work
>
> > I will give the ul an id="gallery"
>
> > var loop = function(){
> >     //current slide
> >     var cur = $("#gallery li:visible");
> >    // fade out current li, on finish fade in next li
> >    cur.fadeOut(500, function(){
> >       // run the loop function again when time is up, in this case 5
> > seconds
> >       cur.next().fadeIn(500, setTimeout(loop, 5000));
> >     });}
>
> > // on the first time wait for 5 seconds before transitioning
> > setTimeout(loop, 5000);
>
> > On Dec 15, 1:39 pm, BarisArt  wrote:
>
> > > I have this list of images:
>
> > > 
> > >   
> > >    > > li>
> > >    > > li>
> > > 
>
> > > What I would like to have is an jQuery method which fades Image1 after
> > > a few seconds and then appears Image2. And so on. After the last
> > > image, Image 1 should be displayed again.
>
> > > Is this possible in jQuery?


[jQuery] Re: .ajaxSend fires six times

2008-12-27 Thread Michael Geary

> > Try something like $('body').ajaxSend(...) if you want just 
> > a single callback.
>
> I tried your suggestion, but never fires the callback.

Well, that's odd that it didn't work. Try a single element by ID then:

$('#someExistingID').ajaxSend(...);

> >$.ajaxStart(function(){
> >$("#loading").show();
> >});
> 
> First i tried this too...

No, I wasn't saying that this would work, only that it would have seemed to
me like a more reasonable design for these functions.

-Mike 



[jQuery] Re: .ajaxSend fires six times

2008-12-27 Thread Lay András

Hello!

On Sat, Dec 27, 2008 at 7:48 PM, Michael Geary  wrote:

> Try something like $('body').ajaxSend(...) if you want just a single
> callback.

I tried your suggestion, but never fires the callback.

>$.ajaxStart(function(){
>$("#loading").show();
>});

First i tried this too...


[jQuery] Re: Please help with navigation script

2008-12-27 Thread precar

Hi,

I cleaned up the code a bit and wanted to repost it.  The site is at
http://pranshuarya.com/test/pthesis/.  Once again, the specific
problem is this:
When you click Portfolio > Refine by category and select a category,
it loads and works fine. But then you cannot re-click on Refine by
category to select another category. The link stops working after it's
been used once.

// display category list in pop-up
$.get('categories.php',function(cats) {
   $('#refine_by').toggle(function() {
  $('#refine_by').text('Click to close');
  $('#categories').append('').append('reset').show('slow').append
('');
  $(cats).find('categories').each(function() {
 var $entry = $(this);
 var $cat = $entry.find('category').text();
 var category = '' + $cat + '';
 $('#categories ul').append($(category));
 });
  $('#category_close').click(function() {
 $('#categories').hide('slow');
 $('#refine_by').text('Refine by category');
 });
  $('#reset_sites').click(function() {
 reset_sites();
 });

// selection from category list
$('#categories ul li').bind('click',function() {
   var index = $('#categories ul li').index(this);
   $.throbberShow({image:'images/ajax-loader.gif', parent:'#sites'});
   $.get(index + ".php",function(data) {
   var $category = $(cats).find('category').eq(index).text();
   $('#sites').empty().append('').append
('Click to close')
   .append('');
   $(data).find('site').each(function() {
  var $entry = $(this);
  var $site_title = $entry.find('site_title').text();
  var html_site = '' + $site_title + '';
  $('#sites ul').append($(html_site));
  });
   cat_box_close();

// site details for category-filtered sites
$('#sites ul li').bind('click',function() {
   var index = $('#sites ul li').index(this);
   $('#site_details').empty().append('');
   $('li:not(this)').removeClass('selected');
   $(this).addClass('selected');
   $imageURL = $(data).find('imageURL').eq(index).text();
   $skills = $(data).find('skills_used').eq(index).text();
   $siteURL = $(data).find('siteURL').eq(index).text();

   var html_image = '';
   $('#site_details').append($(html_image));
   $('#site_details div').addClass('screenshot');

   if($(data).find('imageURL2').eq(index).text() != '') {
  $imageURL2 = $(data).find('imageURL2').eq(index).text();
  var html_image2 = '';
  if($(data).find('siteURL2').eq(index)) {
 $siteURL2 = $(data).find('siteURL2').eq(index).text();
 html_image2 += '';
 }
  else
 html_image2 += '';
  $('#site_details').append($(html_image2));
  $('#site_details div').addClass('screenshot');
  }
   else
  $('#site_details div.screenshot').removeClass
('screenshot').addClass('screenshot_single');

   $('a...@href^=http]').attr({'target': '_blank'}).attr({'title':
'Visit site'});

   if($(data).find('description').eq(index)) {
  $desc = $(data).find('description').eq(index).text();
  var html_desc = '' + $desc + '';
  $('#site_details').append($(html_desc));
  }
   if($(data).find('site_details').eq(index) != '') {
  $details = $(data).find('site_details').eq(index).text();
  var html_details = '' + $details + '';
  $('#site_details').append($(html_details));
  }

   var html_skills = 'Skills used:' + $skills + '';
   $('#site_details').append($(html_skills));
   });
// end of site details for category-filtered sites
   });
});
// End of category list pop-up
},

// other part of toggle function on #refine_by
  function() {
 cat_box_close();
  });
   });


Thanks,
Pranshu.


On Dec 27, 7:29 am, donb  wrote:
> I didn't look too deeply into the code, but I suspect you are
> expecting appended elements to respond to click events, but those new
> elements will have no click event present, only the ones initially
> created by the ready function.
>
> A working example link would be helpful.
>
> On Dec 26, 1:13 pm, precar  wrote:
>
> > Hi,
>
> > Can someone please help me with the following navigation script I'm
> > trying to use on my page?  I have a list of sites in the left div
> > which I would like to be able to filter out.  The issue is that it
> > works only once.  Once I filter once I can't reclick on the "Refine by
> > category" button and change categories or go back to showing all
> > categories.  I'm guessing it's something to do with inner functions,
> > which I don't know enough about yet.  Any help would be greatly
> > appreciated.
>
> > The site is live athttp://pranshuarya.com/test/pthesis.
>
> > The script:
>
> > 
> > $(document).ready(function() {
> >         $('#portfolio').hide();
> >         $('#pfolio_close').hide();
> >         $('#categories').hide();
> >         $('#pfolio').click(function() {
> >                 $.throbberShow({image:'images/ajax-loader.gif', 
> > parent:'#sites'});
> >                 $('#portfolio').show('slow');
> >                 $('#pfolio_close').s

[jQuery] Re: .ajaxSend fires six times

2008-12-27 Thread Michael Geary

I'll bet your document has six DOM elements (HTML tags) in it, right? The
$('*') selector is selecting *all* of those elements, and the ajaxSend
callback is getting called for each one.

Try something like $('body').ajaxSend(...) if you want just a single
callback.

I never noticed it before - I haven't used these ajax event notifications
functions - but this seems like a strange design. They are really global
notifications; it's hard to imagine why they should be attached to
individual DOM elements. Take the example for ajaxStart from the docs:

$("#loading").ajaxStart(function(){
$(this).show();
});

At least to my way of thinking, this would have made more sense as a global
jQuery function:

$.ajaxStart(function(){
$("#loading").show();
});

Ah well, it's water under the bridge now...

-Mike

> From: Lay András
> 
> Hello!
> 
> I need a callback to be executed, when any ajax request 
> begins. I used this code:
> 
> var cnt=0;
> $('*').ajaxSend(function() {
>   cnt++;
> });
> function Teszt() {
>   $.post('jquerytest.php');
>   alert(cnt);
> }
> 
> When i call function Teszt(), the alert shows '6'. Why?
> 



[jQuery] .ajaxSend fires six times

2008-12-27 Thread Lay András

Hello!

I need a callback to be executed, when any ajax request begins. I used
this code:

var cnt=0;
$('*').ajaxSend(function() {
cnt++;
});
function Teszt() {
$.post('jquerytest.php');
alert(cnt);
}

When i call function Teszt(), the alert shows '6'. Why?


[jQuery] Re: question

2008-12-27 Thread Michael Geary
Hi Dirceu,
 
I'm glad that was helpful.
 
Yes, of course I'd be delighted to have you mention my name - and even more
so if you can link it to my blog at http://mg.to/. :-)
 
BTW, you may want to take a look at Google Code as an alternative to
SourceForge. Each one has some advantages and disadvantages, but it's nice
to have a couple of options.
 
-Mike



  _  

From: Dirceu Barquette

Hi Mike,

Fantastic!!! This is very very good!!!
I'll publish this CMS at sourceforge soon, and if you agree your name will
be appear in special thanks. Ok? This is the most important contribution
form my project.
Thank you very much!

Dirceu Barquette


2008/12/24 Michael Geary


I must have been getting forgetful when I posted that suggestion. As I
mentioned, .toSource() is not available in all browsers, so it wouldn't be
suitable for your CMS feature that you want to make available to your site's
visitors.
 
But .toString() *is* available in all browsers, and it gives you the source
code for a function. So you can just use that instead.
 
Here's a test case:
 
http://mg.to/test/jquery-methods.html
 
That page lists all of the jQuery and jQuery() methods in alphabetical
order.
 
The code is:
jQuery(function() {
dump( 'jQuery', jQuery );
dump( 'jQuery()', jQuery.prototype );


function dump( title, object ) {
var list = [];
for( name in object ) {
var fn = object[name];
if( jQuery.isFunction(fn) ) {
list.push( '' + title + '.' + name +
fn.toString().match(/(\([^)]*\))/)[1] + '' );


}
}
$('#list').append( '' + title + ' methods:' +
list.sort().join('') );
}
});
-Mike



[jQuery] Re: Undocumented move/copy behavior of append() et al.

2008-12-27 Thread Markus Gritsch

On Sat, Dec 27, 2008 at 6:40 AM, Dave Methvin  wrote:
>
> Well, like I said back then, jQuery *must* append clones of the nodes
> in the case where you are appending to multiple targets.

Agreed.

> That only
> leaves a question about the one-target-node case. If the default was
> to append a clone in that situation, it wouldn't be possible to select
> nodes and move it to a new location in the DOM tree!

IMO it would have been possible by using a 'moveIfSingleTarget'
boolean-parameter for example or something the like.  This way the
intended behavior would be seen clearly.

The current danger lies in the silent semantic change depending on the
target set count.  Currently it is not obvious that one has to put a
.clone() into the chain to protect the original node from being moved
if the target set happens to contain just one element, whereas the
code without the .clone() works perfectly for cases where more than
one elment matches the selector.

>> At least the current behaviour should be explicitly mentioned in
>> the API documentation.
>
> That would be a good idea. Basically all the methods that insert
> elements documented here are affected:
>
> http://docs.jquery.com/Manipulation
>
> So would the best thing to do be to have some single page that
> describes the behavior, and reference it on that page?

Probably.  This quirk should explicitly be documented, because (at
least to me) it feels quite strange.

Kind regards,
Markus


[jQuery] Re: script behaves different in IE than in Firefox

2008-12-27 Thread lapinkulta

Now i get your point. However, it must be also a jquery issue
as the script and click-count.php works fine in IE.

I also think there are no overlapping requests, as the script
is fired only once when a "a" is clicked.

Still wondering what could be wrong...


[jQuery] Re: More About jQuery's Web Browser Compatibility

2008-12-27 Thread Richard D. Worth
On Fri, Dec 26, 2008 at 11:29 PM, tallvanilla  wrote:

>
> I'm still very interested in knowing the answer to the original
> question.
> Does anyone else care to weigh in? To recap, I just want to know...
>
> 1) minimum version of Camino that is jQuery-compatible


I don't know, though this message would suggest there is one

http://groups.google.com/group/jquery-en/msg/1ef727fdbd7be30b

You could try running the jQuery unit test suite in different versions and
see if any tests fail:

http://jquery.com/test/


>
> 2) whether Safari for Windows is fully jQuery-compatible


Yes


>
> 3) whether Google Chrome (Windows) is jQuery-compatible


Yes

- Richard


[jQuery] Re: jQuery ajax Samples

2008-12-27 Thread donb

Look at the jqGrid plugin source code.  It does all that and more.
Tony has created a well-written plugin that should serve as an
excellent tutorial.  Go to http:trirand.com/blog

On Dec 27, 7:51 am, JQueryProgrammer  wrote:
> Hi All,
>
> I was wondering whether I could find any good basic examples for
> $.ajax where I could find how to use the options of the $.ajax. I
> wanted to see how we can use the dataType: 'xml' / 'json' / 'html' etc
> options to capture respective data and use them. docs.jquery.com
> provides very basic syntax without the server side code.


[jQuery] Re: Please help with navigation script

2008-12-27 Thread donb
I didn't look too deeply into the code, but I suspect you are
expecting appended elements to respond to click events, but those new
elements will have no click event present, only the ones initially
created by the ready function.

A working example link would be helpful.


On Dec 26, 1:13 pm, precar  wrote:
> Hi,
>
> Can someone please help me with the following navigation script I'm
> trying to use on my page?  I have a list of sites in the left div
> which I would like to be able to filter out.  The issue is that it
> works only once.  Once I filter once I can't reclick on the "Refine by
> category" button and change categories or go back to showing all
> categories.  I'm guessing it's something to do with inner functions,
> which I don't know enough about yet.  Any help would be greatly
> appreciated.
>
> The site is live athttp://pranshuarya.com/test/pthesis.
>
> The script:
>
> 
> $(document).ready(function() {
>         $('#portfolio').hide();
>         $('#pfolio_close').hide();
>         $('#categories').hide();
>         $('#pfolio').click(function() {
>                 $.throbberShow({image:'images/ajax-loader.gif', 
> parent:'#sites'});
>                 $('#portfolio').show('slow');
>                 $('#pfolio_close').show('slow');
>                 $('#sites').empty();
>                 $('#site_details').empty();
>                 $('#sites').append('
'); >                 $('#sites').append('
Refine by > category
'); >                 $('#site_details').append('
id="site_details_lower_border"> div>'); > >                 $('#sites').append('
    '); >                 $.get('data.php',function(data) { >                         $(data).find('site').each(function() { >                                 var $entry = $(this); >                                 var $site_title = > $entry.find('site_title').text(); >                                 var html_site = '
  • ' + $site_title + > '
  • '; >                                 $('#sites ul').append($(html_site)); >                         }); >                 }); > >         var showsites = function() { >                 $.get('data.php',function(data) { >                         $('#sites ul li').bind('click',function() { >                                 var index = $('#sites ul li').index(this); >                                 $('#site_details').empty(); >                                 $('#site_details').append('
    id="site_details_lower_border"> div>'); >                                 $('li:not(this)').removeClass('selected'); >                                 $(this).addClass('selected'); >                                 $imageURL = > $(data).find('imageURL').eq(index).text(); >                                 $skills = > $(data).find('skills_used').eq(index).text(); >                                 $siteURL = > $(data).find('siteURL').eq(index).text(); > >                                 var html_image = '
    '; >                                 $('#site_details').append($(html_image)); >                                 $('#site_details div').addClass('screenshot'); > >                                 if($(data).find('imageURL2').eq(index).text() > != '') { >                                         $imageURL2 = > $(data).find('imageURL2').eq(index).text(); >                                         var html_image2 = '
    '; >                                         > if($(data).find('siteURL2').eq(index)) { >                                                 $siteURL2 = > $(data).find('siteURL2').eq(index).text(); >                                                 html_image2 += '
    '; >                                                 } >                                         else >                                                 html_image2 += '
    '; >                                         > $('#site_details').append($(html_image2)); >                                         $('#site_details > div').addClass('screenshot'); >                                         } >                                 else >                                         $('#site_details > div.screenshot').removeClass > ('screenshot').addClass('screenshot_single'); > >                                 $('a...@href^=http]').attr({'target': > '_blank'}).attr({'title': > 'Visit site'}); > >                                 if($(data).find('description').eq(index)) { >                                         $desc = > $(data).find('description').eq(index).text(); >                                         var html_desc = '
    id="description">' + $desc + '
    '; >                                         > $('#site_details').append($(html_desc)); >            

[jQuery] Re: script behaves different in IE than in Firefox

2008-12-27 Thread donb

The server side needs to be aware of and handle multiple overlapping
requests.  It is a problem with your script click-count.php, not the
client side get.


On Dec 27, 3:37 am, lapinkulta  wrote:
> Thank you donb.
> The script counts correct in IE without the alert.
> What should I use instead of .get() ?


[jQuery] Re: JQuery Form Validation and Insert into Database problem

2008-12-27 Thread Jörn Zaefferer
Put your submit code into the submitHandler-callback. See this demo
for an example:
http://jquery.bassistance.de/validate/demo/ajaxSubmit-intergration-demo.html

Jörn

On Fri, Dec 26, 2008 at 4:50 PM, avances  wrote:
>
> I have two scripts, one validates the form and the other enters the
> data into a SQL database without a page refresh. Both scripts work
> fine on there own...
>
> How can I combine them so the form validates and then inserts when
> form is free of errors. Please see the two scripts below. I suspect it
> be very easy but have been searching the net with no luck,
>
> I am using the validate plugin from jquery.
>
>  
>
>
> $(document).ready(function(){
>
>
>  $("#submit").validate ( {
>
> showErrors: function(errorMap, errorList) {
>  $("#warning").html("Tu formulario contiene " +
> this.numberOfInvalids() + " errores.");
>  this.defaultShowErrors();
>  },
>
> debug: false,
> errorElement: "em",
> errorContainer: $("#warning"),
> success: function(label) {
>  label.text("ok!").addClass("success");
> }
>  });
>
>
>$("form#submit").submit(function() {
>
>// we want to store the values from the form input box, then send via
> ajax below
>var fname = $('#fname').attr('value');
>
>$.ajax({
>type: "POST",
>url: "submit_data.php",
>data: "fname="+ fname,
>beforeSubmit:  showRequest,
>success: function(del){
>$('td.success').fadeIn();
>$("#extra").hide();
>$("form#quickcheckbox 
> inp...@name=checkme][type='checkbox']").attr
> ('checked', false);
>$('#submit').resetForm();
>setTimeout(function() { 
> $("td.success").hide(); }, 4000);
>
>}
>});
>return false;
>});
>
>
>
> });
>
>
> 
>


[jQuery] jQuery ajax Samples

2008-12-27 Thread JQueryProgrammer

Hi All,

I was wondering whether I could find any good basic examples for
$.ajax where I could find how to use the options of the $.ajax. I
wanted to see how we can use the dataType: 'xml' / 'json' / 'html' etc
options to capture respective data and use them. docs.jquery.com
provides very basic syntax without the server side code.


[jQuery] Re: Selecting disparate elements in unobtrusive javascript without parameters?

2008-12-27 Thread Michael Geary

Two comments...

1. There's nothing wrong with continuing to have your PHP code generate any
data that makes it easy to write your JavaScript code, such as your m1_div,
m1_link, m1_navlink, etc. jQuery doesn't demand that you do anything
differently.

2. If you do want to generate those other IDs in JavaScript code from a
single piece of information, it is very easy. JavaScript has excellent
string handling facilities. Going back to your proposed solution:

> The only solution apparent to me is to
> 1. grab the links and assign a click function to them
> 2. have the click function get the ID of the link, e.g. "m1_link"
> 3. extract the "base name" from the ID, e.g. "m1_link".replace
> ("_link","") = "m1"
> 4. append "_div" to the base name and use "m1_div" to select the
> appropriate DIV
> 
> That would work fine, but it involves parsing the ID for a name
> component that is "common" to the link and the DIV.

Yes, indeed, that is exactly what you would do. But it's so simple - it
takes less code to do it than describe it. For example:

$(function() {
$('#left a').click( function() {
$( '#' + this.id.replace( '_link', '_div' ) ).doSomething();
});
});

Or another way to do the same thing:

$(function() {
$('#left a').click( function() {
$( '#' + this.id.split('_')[0] + '_div' ).doSomething();
});
});

Or if you have several related elements to operate on:

$(function() {
$('#left a').click( function() {
var base = '#' + this.id.replace( '_link', '_' );
$( base + 'div' ).doSomething();
$( base + 'navlink' ).doSomethingElse();
$( base + 'whatever' ).doWhatever();
});
});

What's not to like?

-Mike

> From: spud
> 
> @Klaus Hartl -- Actually, the code I displayed was simply 
> dummy code as an example; the real code either links to real 
> URIs or isn't an A tag at all.
> 
> Your usage of the hash property, however, does not really 
> provide any more information than the same text used as an 
> ID. So it's an alternative solution, but not really any more 
> efficient.
> 
> I suppose that my problem is conceptual more than anything, 
> since I am also writing the PHP code that generates the 
> output. My PHP code KNOWS
> -- at the moment that output is being generated -- what the 
> IDs of all the related components are ("m1_div, m1_link, 
> m1_navlink"). So it was convenient to hard-code these values 
> in an inline onclick handler.
> 
> The demands of jQuery-style javascript, however (and I'm not 
> arguing about the logic of this method), is that my PHP code 
> should ignore the information it has, and Javascript will 
> re-create that information by parsing information from the 
> link (whether in the hash or the ID) later on. It seems like 
> extra work, but it does make things more flexible.
> 
> spud.
> 
> On Dec 26, 6:45 pm, Klaus Hartl  wrote:
> > You said you don't want to litter your code with bogus 
> classes, but - 
> > speaking of unobtrusive - you do litter it with bogus anchors 
> > (href="#"). That said, the most obvious solution to me is to give 
> > these anchors a little more meaning by letting them point 
> to the div 
> > they seem to be connected to anyway:
> >
> > Module 1
> >
> > Such semantically improved HTML will also make your 
> scripting easier 
> > (and theoretically - even if it may be not too much of a 
> concern in a 
> > CMS, it will degrade more gracefully).
> >
> > In your jQuery code you can then easily rely on the hash 
> property to 
> > access the associated elements, thus you get a pretty generic, 
> > straightforward solution:
> >
> > $('a').click(function() {
> >     var fragment = $(this.hash); // a div in our case
> >     // do something with fragment, for instance toggle
> >     // so something else
> >
> > });
> >
> > --Klaus
> 



[jQuery] Re: script behaves different in IE than in Firefox

2008-12-27 Thread lapinkulta


Thank you donb.
The script counts correct in IE without the alert.
What should I use instead of .get() ?