[jQuery] Re: Selecting a span within a cell

2009-03-02 Thread RWF

thank you so much mkmanning.

On Mar 2, 10:25 am, mkmanning  wrote:
> $('#blah').parents('td').prev().find('span.Validator')
>
> On Mar 2, 8:14 am, RWF  wrote:
>
>
>
> > Given this structure:
> > 
> >         
> >             
> >                   *hello
> >             
> >             
> >                 
> >             
> >         
> >     
>
> > If i only know the ID of the checkbox input, how can I select the span
> > that has a "Validator" class?


[jQuery] Selecting a span within a cell

2009-03-02 Thread RWF

Given this structure:



  *hello







If i only know the ID of the checkbox input, how can I select the span
that has a "Validator" class?


[jQuery] Re: Performance penalty for creating dom element from a string?

2009-01-14 Thread RWF

This also confused me. I tried creating the element as the1.3 docs
show (as noted in the OP) and then appending it to a div and it did
not generate a closing tag. This is what I did:
var image=$("");
image.alt="hello world";

$("#maindiv").append(image);

The result was a single  without a / like this:


Am I misunderstanding something?

On Jan 14, 3:13 pm, Ricardo Tomasi  wrote:
> With the string, jQuery has to parse it, to find the tagname and any
> attributes. For a dozen elements it doesn't make any real difference,
> but when you get to the hundreds or thousands of elements it's
> significant:
>
> 100 elements:
> String: 34ms
> DOMElement: 5ms
>
> 1000 elements:
> String: 339ms
> DOMElement: 40ms
>
> This in Firefox 3, Core 2 Duo 1.6ghz, using Firebug (code below).
>
> cheers,
> - ricardo
>
> (function(){
> var i=1001, r=i;
> console.time('string');
> while(--i){
>  $('');}
>
> console.timeEnd('string');
>
> i=r;
> console.time('DOMEl');
> while(--i){
>   $(document.createElement('div'));};
>
> console.timeEnd('DOMEl');
>
> })();
>
> On Jan 14, 3:04 pm, thomasvsundert 
> wrote:
>
> > Hi,
> > the new documentation for jQuery 1.3 states that:
>
> > "To create a span use $(""). As of jQuery 1.3 this syntax is
> > completely equivalent to $(document.createElement("span"))."
>
> > First of all, what does this mean? What was the difference before?
>
> > My real question is, what is the performance penalty for using $("
> > >") vs $(document.createElement("div"))
>
> > thanks,
> > Thomas


[jQuery] Re: jsonp to WCF problem

2008-10-24 Thread RWF

thanks tenacious for all the help.  It sounds like i would just ditch
my IIS hosted WCF service, i was under the impression from this link:
http://msdn.microsoft.com/en-us/library/cc716898.aspx
that it was some how possible to rig WCF to format the response
natively but the solution it referrers to does not exist in the
samples download.

On Oct 24, 9:00 am, tenaciousd <[EMAIL PROTECTED]> wrote:
> Er, "bugger" should've been "buffer".  Quite a typo.
>
> On Oct 24, 9:58 am, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > My service setup isn't exactly the same as yours but I think the same
> > solution will work for you.
>
> > You'll need to add two classes, one that inherits from Stream (we'll
> > call is JsonStream) and another that inherits from the IHttpModule
> > interface (we'll call this JsonModule).  The JsonStream class will
> > need a public property to store the name of the callback (e.g.
> > CallbackFunctionName).
>
> > JsonModule's Init needs to first look for all RequestType = GET and,
> > for all such requests, do a GetValues on "callback" to see if the
> > caller expects us to make a callback or simply return data.  If a
> > callback param is present we need to create a new instance of
> > JsonStream passing the current context's Response.Filter to the
> > constructor and then set CallbackFunctionName to the appropriate
> > value.  Then, in JsonStream in the overridden Write method, if
> > CallbackFunctionName has a value you need to do something like (where
> > _stream is the value passed into JsonStream's constructor):
>
> > string content = CallbackFunctionName + "(" +
> > Encoding.UTF8.GetString(bugger) + ");";
> > _stream.Write(Encoding.UTF8.GetBytes(content), 0, content.Length);
>
> > In this way you've decoupled the callback functionality from yourWCF
> > service(s) but it "just works" for cases that require it.  Hopefully
> > this implementation will work in your scenario.
>
> > On Oct 24, 9:22 am, RWF <[EMAIL PROTECTED]> wrote:
>
> > > Thanks for the info.  How exactly are you writing directly to the
> > > response usingWCF?  My IIS hostedWCFservice is basically just
> > > acting like a proxy to a windows hostedWCFservice, so they both use
> > > the same contract, but the IIS hosted service is a REST based
> > > service.  Is there a way to maintain this uniformity of contracts,
> > > while writing directly to the response of the IIS service?
>
> > > On Oct 23, 8:22 am, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > > > If you're going to do cross-domain calls you can't do a POST, only a
> > > > GET.  I think even if you specify POST as your type jQuery will
> > > > convert it to a GET if your datatype isjsonp(check their doc but I'm
> > > > pretty sure that's the case).
>
> > > > As forWCFthe key is just making sure that you wrap your return in
> > > > the callback method and write it to the Response.  In other words, you
> > > > can't simply have aWCFendpoint that returns a json-formatted
> > > > object.  Instead you need to write something like
> > > > "callbackMethodName(" + yourJSONObject + ");" to the Response.  Once
> > > > you've done this jQuery will execute the callback call, in which it
> > > > will do an eval() on yourJSONObject and then call the success method,
> > > > passing it the JSON object in the data parameter.  At that point you
> > > > will have dot notation on your JSON object.
>
> > > > On Oct 22, 7:31 pm, RWF <[EMAIL PROTECTED]> wrote:
>
> > > > > I am usingWCFtoo, have you done projects that require an $.ajax POST
> > > > > request to aWCFservice cross site?  If you have, how did come up
> > > > > with a server proxy to allow for cross site communication?
>
> > > > > On Oct 10, 2:01 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > > > > > Nevermind.  The fundamental issue was that the json object wrapped 
> > > > > > in
> > > > > > the callback name does, in fact, need to be written to the Response.
> > > > > > I'm an idiot.  Anyway, it's working now.  If others hit the same
> > > > > > jquery ->jsonp->wcfissue let me know.
>
> > > > > > On Oct 10, 12:07 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I'm using jQuery

[jQuery] Re: jsonp to WCF problem

2008-10-24 Thread RWF

Thanks for the info.  How exactly are you writing directly to the
response using WCF?  My IIS hosted WCF service is basically just
acting like a proxy to a windows hosted WCF service, so they both use
the same contract, but the IIS hosted service is a REST based
service.  Is there a way to maintain this uniformity of contracts,
while writing directly to the response of the IIS service?

On Oct 23, 8:22 am, tenaciousd <[EMAIL PROTECTED]> wrote:
> If you're going to do cross-domain calls you can't do a POST, only a
> GET.  I think even if you specify POST as your type jQuery will
> convert it to a GET if your datatype is jsonp (check their doc but I'm
> pretty sure that's the case).
>
> As for WCF the key is just making sure that you wrap your return in
> the callback method and write it to the Response.  In other words, you
> can't simply have a WCF endpoint that returns a json-formatted
> object.  Instead you need to write something like
> "callbackMethodName(" + yourJSONObject + ");" to the Response.  Once
> you've done this jQuery will execute the callback call, in which it
> will do an eval() on yourJSONObject and then call the success method,
> passing it the JSON object in the data parameter.  At that point you
> will have dot notation on your JSON object.
>
> On Oct 22, 7:31 pm, RWF <[EMAIL PROTECTED]> wrote:
>
> > I am using WCF too, have you done projects that require an $.ajax POST
> > request to a WCF service cross site?  If you have, how did come up
> > with a server proxy to allow for cross site communication?
>
> > On Oct 10, 2:01 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > > Nevermind.  The fundamental issue was that the json object wrapped in
> > > the callback name does, in fact, need to be written to the Response.
> > > I'm an idiot.  Anyway, it's working now.  If others hit the same
> > > jquery ->jsonp-> wcf issue let me know.
>
> > > On Oct 10, 12:07 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > > > I'm using jQuery $.ajax to make a cross-domainjsonpcall to a WCF
> > > > service.  The call is working fine, entering the service endpoint, but
> > > > the callback method never fires.  I've tried many permutations of
> > > > changes and can't seem to get this to work.
>
> > > > The WCF endpoint is returning a string (NOT doing a Response.Write)
> > > > that contains a json object inside the callback wrapper (e.g.
> > > > "jsonp123( {"Author":"John Doe","Price":"$35.90"} )" ) and the content-
> > > > type returned from the service is application/json; charset=utf-8.
>
> > > > $.ajax call is below.  Any help is much appreciated.
>
> > > >         var data = {"ISBN" : $("#isbn1").val()};
>
> > > >         $.ajax({
> > > >                 type: "GET",
> > > >                 cache: false,
> > > >                 url: "http://localhost:63132/Widget.svc/GetProductInfo";,
> > > >                 scriptCharset: "utf-8",
> > > >                 dataType: "jsonp",
> > > >                 data: data,
> > > >                 success: function(data, textStatus){
> > > >                         alert("success");
> > > >                 },
> > > >                 error: function(XMLHttpRequest, textStatus, 
> > > > errorThrown){
> > > >                         alert('error');
> > > >                 }
> > > >         });


[jQuery] Re: jsonp to WCF problem

2008-10-22 Thread RWF

I am using WCF too, have you done projects that require an $.ajax POST
request to a WCF service cross site?  If you have, how did come up
with a server proxy to allow for cross site communication?

On Oct 10, 2:01 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
> Nevermind.  The fundamental issue was that the json object wrapped in
> the callback name does, in fact, need to be written to the Response.
> I'm an idiot.  Anyway, it's working now.  If others hit the same
> jquery ->jsonp-> wcf issue let me know.
>
> On Oct 10, 12:07 pm, tenaciousd <[EMAIL PROTECTED]> wrote:
>
> > I'm using jQuery $.ajax to make a cross-domainjsonpcall to a WCF
> > service.  The call is working fine, entering the service endpoint, but
> > the callback method never fires.  I've tried many permutations of
> > changes and can't seem to get this to work.
>
> > The WCF endpoint is returning a string (NOT doing a Response.Write)
> > that contains a json object inside the callback wrapper (e.g.
> > "jsonp123( {"Author":"John Doe","Price":"$35.90"} )" ) and the content-
> > type returned from the service is application/json; charset=utf-8.
>
> > $.ajax call is below.  Any help is much appreciated.
>
> >         var data = {"ISBN" : $("#isbn1").val()};
>
> >         $.ajax({
> >                 type: "GET",
> >                 cache: false,
> >                 url: "http://localhost:63132/Widget.svc/GetProductInfo";,
> >                 scriptCharset: "utf-8",
> >                 dataType: "jsonp",
> >                 data: data,
> >                 success: function(data, textStatus){
> >                         alert("success");
> >                 },
> >                 error: function(XMLHttpRequest, textStatus, errorThrown){
> >                         alert('error');
> >                 }
> >         });


[jQuery] Clarification on the use of JSONP in $.ajax

2008-10-22 Thread RWF

in the docs: http://docs.jquery.com/Ajax/jQuery.ajax#options

it says:

As of jQuery 1.2, you can load JSON data located on another domain if
you specify a JSONP callback, which can be done like so: "myurl?
callback=?". jQuery automatically replaces the ? with the correct
method name to call, calling your specified callback. Or, if you set
the dataType to "jsonp" a callback will be automatically added to your
Ajax request.
*


Is there an example of this?  This makes it sound like I can make a
cross site request to a webservice that returns a JSON object and
jquery will handle the rest.