[jQuery] Re: image refresh problem due to browser cache

2009-11-29 Thread Kris
I'm interested in this and found this: http://drupalbin.com/8159


[jQuery] Unable to detect Ajax cross domain error (Firefox)

2009-10-07 Thread Kris Schoofs

Hi,

Using Firefox 3.5.3 (and firebug) I run the Ajax code below locally
(i.e. not on the same domain as the Ajax URL). Unlike in IE, this code
is not working in Firefox due to cross-domain Ajax restrictions. Of
course, as soon as I upload the code to my PHP server on the same
domain it runs fine.

However, when running the code locally the 'error'-callback never gets
triggered. Instead, the 'success'-callback always get triggered even
though the request clearly failed (as confirmed by the fact that
'OnSuccess' is unable to show any data received from the server). Even
firebug does not report any errors. Somehow, I expected to see an
error like "Permission denied to call method XMLHttpRequest.open".

I would feel much more comfortable about my code when I was 100% sure
that I can catch all errors. So, I'm wondering why I'm unable to
detect this obvious error?

$.ajax({
    type: "GET",
    url: "http://dvd.identifier.cdfreaks.com/alive2.php";;,
    cache: false,
    data: "para1=value1¶2=value2",
    success: function(data, textStatus)
    {
        $("#container_onsuccess").html("@"+Counter+"#"+data+"#"+textStatus);
    },
    error: function (XMLHttpRequest, textStatus, errorThrown)
    {
        
$("#container_onerror").html("@"+Counter+"#"+textStatus+"#"+errorThrown);
    },
    complete: function (XMLHttpRequest, textStatus)
    {
        $("#container_oncomplete").html("@"+Counter+"#"+textStatus);
        Counter++;
        ScheduleNextAjaxRequest();
    }
});

Thanks,

Kris


[jQuery] Click event not working?

2009-08-27 Thread Kris S

I'm trying to execute a function "animate_next()" when a "div" element
is clicked, but it isn't working. Here is what it looks like..

$('#playground').click(function(){animate_next();});

If I put..

$('#playground').ready(function(){animate_next();});

..then it will work fine.

Here is the "div" element on the page..




[jQuery] newbie question.

2009-07-25 Thread Kris

What does this do?
(function($) { do some stuff } )(jQuery);


[jQuery] Re: Text manipulation : retrieve tag

2009-07-23 Thread Kris-I

In fact all the text/code is in a variable, it's not display on the
screen.

The page is more like this :

*strong text*

MyMessage

 body {font-family:"Verdana";font-weight:normal;font-size: .
7em;color:black;}
 




Server Error in '/' Application.
 MyMessage 
 Exception Details: System.Exception: MyMessage




On Jul 23, 1:41 pm, Charlie  wrote:
> I don't believe title tag is valid in body tag however regardless of tag 
> placement try this 
> alert($('title').text());


[jQuery] Text manipulation : retrieve tag

2009-07-23 Thread Kris-I

Hello,

I have an HTML text with text and tags

I'd like to get only the text between the tags 

Then I have this:


start text
Text to get
end text


i'd like to have this result ONLY: "Text to get"

How can I do this ?

Thanks,


[jQuery] Catch Exception

2009-07-22 Thread Kris-I

Hello,

In my code (ASP.NET MVC using Nhibernate) , I do this :

$(document).ready(function() {
$('.DOFFDelete').click(function() {
var id = $(this).attr("id");
$.post("/Customer/DayOffDelete", { customerid:
getCustomerId(), doffId: id }, function(data) {
$("#myFormDOFF").html(data);
});
});
});

Then I display the result in the DIV named "myFormDOFF"

Of course, my .NET code can generate exception. I'd like when I
receive an exception didn't change the content of "myFormDOFF" but
display the message send by the exception in another DIV. How can I do
this ?

Thanks,


[jQuery] keypress, keydown + backspace : Firefox, Chrome, IE

2009-07-21 Thread Kris-I

Hello,

I check the keycode, for all input (text) of the page, like this :
$(document).ready(function() {
$("input[type=text]").bind('keypress', function(e) {

var code = (e.keyCode ? e.keyCode : e.which);

if (code != 0 && code != 9 && code != 45 && code != 99) {
...
}
});
});

But for one specific input, I do this (number only) :
$(document).ready(function() {
$("#HourByWeek").keypress(function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code != 8 && code != 0 && (code < 48 || code > 57)) {
return false;
}

if (code != 0) {
..
}
});

I'd like in the first function, place an exception for HourByWeek, how
can I do this ?

With firefox 3.x no problem, bt with Chrome 2.x and IE8, I don't have
any code for the backspace, the backspace is not catched by the
keypress. What is the best way to solve this ?

Thanks,


[jQuery] no intellisense ...

2009-06-01 Thread Kris-I

Hello,

I'm running Visual Studio 2008 SP1 on Windows 7 RC, I installed the
KB958502, get the files jquery-1.3.2-vsdoc2.js and jquery-1.3.2.js
placed in the root (but I tried other places) with the code below ...
no intelisense .

Do you have an idea why ?

Thanks,


<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="jQueryTest._Default" %>



http://www.w3.org/1999/xhtml"; >


Follow me!



$(function(){
$("

Hi there!

").insertAfter("#followMe"); }); Follow me!

[jQuery] Re: mod_python and ajax - no Hello world examples exist

2009-05-28 Thread kris

To see how to do it with Javascript:

http://vandermerwe.co.nz/?p=9

(figured it out myself)

Regards
Kris

On May 24, 6:20 pm, kris  wrote:
> Im trying to implement Ajax under mod_python.
> Mod_python works fine for normal pages, but i cant get a Ajax
> response.
>
> Does somebody know of a "hello world" example for Ajax and mod_python
> and jQuery?
>
> My test is something like this, HTML client:
>                 $("#test_form").submit(function() {
>                         var nmval = $("#username").val();
>                         var pwval = $("#password").val();
>                         $.post("/test/ajax101", { username: nmval, password: 
> pwval },
>                            function(data) {
>                                 alert(data);
>                                 $("#response").html(data);
>                         });
>                 });
>
> With the Ajax submit of #test_form i get a small amount of (disk)
> activity, but "/test/ajax101.py" never seems to get anything back to
> the the browser (I tried an alert and write to a dom object)
>
> Any pointers appreciated


[jQuery] mod_python and ajax - no Hello world examples exist

2009-05-24 Thread kris

Im trying to implement Ajax under mod_python.
Mod_python works fine for normal pages, but i cant get a Ajax
response.

Does somebody know of a "hello world" example for Ajax and mod_python
and jQuery?

My test is something like this, HTML client:
$("#test_form").submit(function() {
var nmval = $("#username").val();
var pwval = $("#password").val();
$.post("/test/ajax101", { username: nmval, password: 
pwval },
   function(data) {
alert(data);
$("#response").html(data);
});
});

With the Ajax submit of #test_form i get a small amount of (disk)
activity, but "/test/ajax101.py" never seems to get anything back to
the the browser (I tried an alert and write to a dom object)

Any pointers appreciated


[jQuery] combined url

2009-03-10 Thread Kris

Hi

I'm new to jquery i can't understand what the followng means.


var combinedIncludeURL = "combine.php?type=javascript&files=";
can i modified that ?

my requirement is can i call jsp instead of this?
plz help me


[jQuery] Re: Little help please?

2009-02-16 Thread Kris

Michael,
Thanks very much for your reply. It has cleared many things up for me
and can see now why I was having trouble. I will take your advice and
make an object rather than a jquery plugin.
Thanks very much.
Kris.


[jQuery] Little help please?

2009-02-15 Thread Kris

Hi Guys,
I'm playing around with writing plugins. To learn I decided to write a
plugin which interfaces with Google Maps. My code is as follows:

jQuery.fn.extend({
googlemap : function(lat,lng,zoom) {
return this.each(function(){
if (GBrowserIsCompatible()) {
map = new GMap2(this);
map.setCenter(new GLatLng(lat, lng),
zoom);
}
});
},
pan : function(lat,lng, delay) {
return this.each(function(){
window.setTimeout(function() {
map.panTo(new GLatLng(lat,lng));
}, delay);
});
},
infoWindow : function(lat,lng, nodeText) {
return this.each(function(){
map.openInfoWindow(new GLatLng(lat,lng),
document.createTextNode
(nodeText));
});
}

});

Now, this all works wonderfully if I only have one map per page, like
so:

$("#map").googlemap(37.4419, -122.1419, 10);

$("button").click(function(){
$("#map").pan(37.3, -122.2, 0);
$("#map").infoWindow(37.4419, -122.1419, "Hello");

});



However, if I have more than one map, like so:

$("#map").googlemap(37.4419, -122.1419, 10);
$("#map2").googlemap(37.4419, -122.1419, 10);

$("button").click(function(){
$("#map").pan(37.3, -122.2, 0);
$("#map2").infoWindow(37.4419, -122.1419, "Hello");

});




The pan and infoWindow only act on the last . I'm sure this is
only because of a rookie javascript mistake, any help is much
appreciated.
Many thanks,
Kris.


[jQuery] Re: validation remote

2009-02-08 Thread Kris

Another figure out the solution for this? I am having a similar
problem.

Thanks guys,
Kris

On Dec 15 2008, 4:17 am, Jet  wrote:
> Hi,
>
> Sounds like we are having the same problem.
>
> I have posted about the problem in this thread.
>
> http://groups.google.com/group/jquery-en/browse_thread/thread/5d29f6e...
>
> The thread above though refers to a field not usingremote, but I'm
> also having the same problem on another page when usingremote.
>
> URL:http://www.thaidatelink.com/account/register/
>
> (checkout the "Username" field which I'm using "remote".)
>
> Well...sorry I'm not of much help.
>
> Just to bring to your attention about this similar thread and hope
> that Jörn (the author of this wonderful script) could help.
>
> Good luck!
>
> ;)
>
> On Dec 15, 4:48 am, kemalemin  wrote:
>
> > Hi, myvalidationsummary worked quite fine before I made aremote
> > username check available to it. The problem is when for the first time
> > an already existing username is entered into the username box, the
> > error div pops alright saying that the username already exists in the
> > db. however when I go back and correct it, the error message
> > disappears but the containing div still exists on the page. below is
> > the code, I hope somebody can help
>
> >  var container = $('#error_container');
> >         // validate the form when it is submitted
> >         var validator = $("#frmUserRegister").validate({
> >             onkeyup: false,
> >                 errorContainer: container,
> >                 errorLabelContainer: $("ol", container),
> >                 wrapper: 'li',
> >                 meta: "validate",
> >                 rules: {
> >             txtFullName: {
> >                 required: true,
> >                 rangelength:[3, 100]},
> >             txtUsername: {
> >                 required: true,
> >                 rangelength:[5, 30],
> >                remote:"ajaxCheckUsername.aspx"}, // returns 'true' or
> > 'false' as string
> >             txtEmail: {
> >                 required: true,
> >                 email: true},
> >             txtPassword: {
> >                 required: true,
> >                 rangelength:[5, 20]},
> >             txtConfirmPassword: {
> >                 equalTo: "#txtPassword"}
> >         },
>
> >         messages: {
> >             txtFullName: {
> >                 required: "Please enter your full name > strong>.",
> >                 rangelength: "Fullname must be between 3 and
> > 100 characters"},
> >             txtUsername: {
> >                 required: "Please enter a valid username > strong>.",
> >                 rangelength: "Username must be between 5 and
> > 30 characters.",
> >                remote: jQuery.format("{0} is already
> > taken, please choose a different username.")},
> >             txtEmail: {
> >                 required: "please provide an email
> > address.",
> >                 email: "please provide a valid email
> > address"},
> >             txtPassword: {
> >                 required: "please provide a password > strong>",
> >                 rangelength: "Password must be  between 6 and
> > 20 characters"},
> >             txtConfirmPassword: {
> >                 equalTo: "passwords must match."}
> >         },
> >         });
>
> > });
>
> >     
>
> >     
> > #error_container
> > {
> >     background-image:url(img/error.gif);
> >     background-repeat:no-repeat;
> >         background-color: #FFE8E8;
> >         border: 1px solid #CC;
> >         color: #CC;
> >     font-family:Tahoma;
> >     font-size:11px;
> >     padding:4px 0 0 40px;
> >     display: none;
>
> > }
>
> > #error_container ol li {
> >         list-style-type:circle;
>
> > }
>
> > form.frmUserRegister label.frmUserRegister, label.error {
> >         /* remove the next line when you have trouble in IE6 with labels in
> > list */
> >         color: #CC;
>
> > }
>
> > 
> > 
> > 
> >     
> >     
> >         please review and correct the following errors:
> >         
> >             
> >         
> >         
>
> >  the rest of the page are the form fields...
>
> > here, the div with the id of "error_container" is still being
> > displayed...
>
>


[jQuery] Re: Prefixing all href attributes (or how to get .attr('href') to return a string)

2008-12-11 Thread Kris

Own workaround:

if(document.domain=='localhost') { var root_url = 'http://localhost/
project/'; } else { var root_url = 'http://www.mydomain.com/inprog/
project'; }
 $("#content_main a:not(.external)").attr('href', function() {
  orig_url = $(this).attr('href');
  if(orig_url.substring(0,4)=='http') { orig_url = orig_url.substr
(root_url.length,orig_url.length); } // IE Fix
  return path_prefix + orig_url;
});


[jQuery] Re: Prefixing all href attributes (or how to get .attr('href') to return a string)

2008-12-11 Thread Kris

Okay the only issue I'm facing now and its not strictly a JQuery one,
its more an IE one...

HREF's like 'images/trucks.jpg' should be prefixed with 'cms/' giving
'cms/images/trucks.jpg'.

Firefox and Safari are okay, I get URLs like:

http://www.mydomain.com/inprog/cvs/cms/images/trucks.jpg

But in IE it adds the entire URL twice...

http://www.mydomain.com/inprog/cvs/cms/http://www.mydomain.com/inprog/cvs/images/trucks.jpg

Why would this be, I'm guessing IE is returning the entire URL for
href, not just what is present in the attribute? Any way around this?

var path_prefix = 'cms/';
$("#content_main a:not(.external)").attr('href', function() {
  return path_prefix + $(this).attr('href');
});


[jQuery] Re: Setting background image does not work...

2008-12-11 Thread Kris

I see, the path is not relative to the css file (../images/banner/
default.gif) that first set background, its relative to root (images/
banner/custom.gif).
Many thanks for confirming I had correct syntax, one of those where
you can bang your head aginst the walls for days!!


[jQuery] Re: Prefixing all href attributes (or how to get .attr('href') to return a string)

2008-12-11 Thread Kris

Many thanks Karl, I never would have got there without help.



On Dec 10, 5:10 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> Hi Kris,
>
> The problem is that $(this) is referencing something other than the  
> link at that point -- either some enclosing method or the window  
> object. You can get around this by using a callback function as the  
> second argument of .attr() :
>
> $("#content_main a").attr('href', function() {
>    return 'cms/' + $(this).attr('href');
>
> });
>
> --Karl
>
> 
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Dec 10, 2008, at 9:59 AM, Kris wrote:
>
>
>
> > I'm trying to use the below code to prefix all href's with 'cms/'...
>
> > [code]
> > $("#content_main a").attr('href', 'cms/' + $(this).attr('href'));
> > [/code]
>
> > I end up with href's which look like this "cms/undefined". I guess I
> > need to get $(this).attr('href') to return a string instead of a
> > JQuery object?
>
> > Many thanks, K.


[jQuery] Prefixing all href attributes (or how to get .attr('href') to return a string)

2008-12-10 Thread Kris

I'm trying to use the below code to prefix all href's with 'cms/'...

[code]
$("#content_main a").attr('href', 'cms/' + $(this).attr('href'));
[/code]

I end up with href's which look like this "cms/undefined". I guess I
need to get $(this).attr('href') to return a string instead of a
JQuery object?

Many thanks, K.



[jQuery] Setting background image does not work...

2008-12-10 Thread Kris

I have tried both the following but neither seem to work.

[code]
$('#content-top').css('backgroundImage', "url(" + src + ")");
$('#content-top').css("background-image", "url(" + src + ")");
[/code]

Any ideas would be welcome, thanks.


[jQuery] infinite jQuery

2008-09-27 Thread Kris

Hi all,

I'm really excited about jQuery, just as all the rest here. I've found
out that it is really easy to create an animation. However, one day I
stumbled upon the following question: is it possible to run one
animation infinitely (repeat one statement the whole time, in my
case).
Is that even possible with Javascript? And by this, I really mean:
while(true);

My webbrowser always seems to crash when I do infinite javascript. And
I feel really dissapointed, because it looks like there is a constrait
here with ECMA. Should I really use other technologies like Flash or
Silverlight?

I would like to hear your ideas about infinite loops in Javascript. Is
this a possibility? Even if you think it might be a commodity in the
future, say so. Thank you.


[jQuery] selecting div's with dynamic id's

2008-07-04 Thread Kris

Whats the best way to provide functionality (eg. toggle an 'additional
information' div) when dealing with records with unique id's.

For example lets say we are dealing with product records each one has
a unique id which is a number, so the HTML might look something like
this:


  
Name: Red Widget
Price: 22.00
Show description
sadasdasdasdasd
  

  
Name: Blue Widget
Price: 24.00
Show description
sadasdasdasdasd
  

etc. etc.


I want to place unobtrusive jquery that will allow the 'show
description' link to display the correct description div...

Many thanks, K.




[jQuery] ajax sending back redirect breaks history

2008-01-19 Thread Kris

I'm wondering whether there is a workaround or something I missed, or
should i file a bug.

When you make an ajax submit (with the jquery forms plugin), and you
set the dataType to 'script', and the server returns

window.location.href='some new location';

it successfully redirects, but instead of doing a location change it
actually seems to do the equivalent of a window.replace(), because the
browser no longer has the previous page in its history.

I tested this on windows xp with firefox 2 and IE 7.  If I use
prototype in the exact same manner it works as i would expect keeping
history intact, so i assume something specific is being done in the
jquery module either on purpose or by accident.

Any ideas or comments welcome.

kris


[jQuery] Re: Jquery Location.href or load --problem

2007-09-30 Thread Kris Kowal
You might consider::

window.location.href = fullyQualifiedUrl;

``href`` is not a function, although the notion (arguably a jQuery idiom)
that assignment could be implied by application on a non-function is fun.

 Kris Kowal

On 9/29/07, voltron <[EMAIL PROTECTED]> wrote:
>
>
> Hi all, I would like to call up a page using location.href  or Ajax in
> the Jquery way, I ried this:
>
> $("#preview_button").click(function(){
>$("#main").load("/de/testsite/preview_profile");
>   });
>
> and this
>
> $("#preview_button").click(function(){
>window.location.href("/de/testsite/preview_profile");
>   });
>
>
> Strangely, both methods do not work, anyone tell me what I´m doing
> wrong?
>
>
> Thanks
>
>


[jQuery] Re: using load cross site

2007-09-10 Thread Kris Zyp

Here is the JSONP proposal: 
http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
Yahoo also uses the same approach (with a different callback
parameter): http://developer.yahoo.com/common/json.html
And I just released CrossSafe, which lets you securely use JSONP/XSS
with callback: http://www.xucia.com/page/CrossSafe
Kris

On Aug 13, 11:06 pm, Hector Santos <[EMAIL PROTECTED]> wrote:
> But Michael, please excuse my ignorance. I'm curious. I have to ask
> because I still do not see this "JSONP XSS loophole."
>
> Isn't this flickr example you showed below is selft containing with
> the same site I/O? Where is the cross-site logic?
>
> Do you have a link to some official or 'proposal' or draft
> specification on JSONP?
>
> --
> HLS
>
> On Aug 13, 7:35 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
>
>
>
> > No, you can load *scripts* cross-site with no problem.
>
> > It's true, a server-side proxy is the only way to do a cross-site Ajax
> > download. But if the information is available in any kind of executable
> > JavaScript format, you can use a script tag or a dynamic script element to
> > download it.
>
> > That's what the JSONP (JSON with callback) format is all about - wrap a JSON
> > object inside a callback function whose name is given in the request URL.
> > Here's an example:
>
> >http://www.flickr.com/services/feeds/photos_public.gne?format=json
> > <http://www.flickr.com/services/feeds/photos_public.gne?format=json&js...
> > back=fotofeed> &jsoncallback=fotofeed
>
> > That URL returns:
>
> > fotofeed({
> >   "title": "Everyone's photos",
> >   "link": "http://www.flickr.com/photos/";,
> >   // more stuff here, including an array of photo links and info
>
> > })
>
> > If you create either a script tag or a dynamic script element with that URL
> > in the src, it will call your "fotofeed" function (or any function you name
> > in the jsoncallback= URL parameter) and pass it the JSON data.
>
> > It doesn't have to be JSON data, of course - the script tag can execute any
> > JavaScript code (which can be good or bad - obviously you need to trust the
> > data provider). JSONP is just a common convention for downloading JSON data
> > cross-domain.
>
> > If you want to make sure that no rogue JavaScript code is executed, or if
> > the data isn't available in JSONP or a similar executable script format,
> > then you do need to Ajax and a server-side proxy.
>
> > -Mike
>
> >   _
>
> > From: Matt Stith
>
> > The only way around is to use a server-side script as a proxy, as loading
> > scripts cross-site is a security risk, which is why browsers block that out.
>
> > From: Anthony Leboeuf(Worcester Wide Web)
>
> > I am working on a website for the BBB and need to load a document cross
> > site, I am getting apermissiondeniedmessage when doing so. Is there a
> > way around that?- Hide quoted text -
>
> - Show quoted text -