Michael Hubele

Ranch Hand
+ Follow
since Dec 17, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Michael Hubele

Bear Bibeault wrote:

Now I don't know why but sometimes my server hangs but then again I am guessing all servers hang since sometimes when I go to sites it take forever to load but if you do a refresh it loads up instantly and that's the same case with my site.


No, this is not normal. You need to find out why this is happening.



where should I start. Seem like every site I go to has this. Like is it a code problem?
Hi

I am not really sure what to do in this situation. I have some jquery ui 1.7 tabs that are ajax enabled. Now when a tab is clicked it goes to my asp.net mvc controller action method. That then does whatever is needed and return a partial view(return some html).

Now I don't know why but sometimes my server hangs but then again I am guessing all servers hang since sometimes when I go to sites it take forever to load but if you do a refresh it loads up instantly and that's the same case with my site.

My site will load up a tab super fast for X number of times then all of a sudden a request will just hang and maybe like 15seconds later it will load up. Or if you just refresh the page it will go back and start loading them up super fast again.

The problem though is the request is sent to the server where it hangs. So I tried to setup a jquery timeout on all my ajax stuff and that calls an abort to the jquery ui tabs.

But it never works and I guess from what I gathered is because the request is on the server and abort won't stop stuff on the server. So if I look at firebug that request that hanged is still running.

Now this causes a huge problem for me since it screws up the entire page what is heavily ajax(disable javascript and the page is useless). Like if the user tries to click on say another tab they will most likely have to click 2 times to get it to load up. Another thing what happens is if that request ever finish hanging whatever tab they are on will merge with that tab. So sometimes one tab will have parts from all the other tabs.

So if it hangs and does not finish it really messes with the ajax tabs. I have no clue how to fix this.

So I am not sure what to do.

Let them hang for however long it takes the server to figure out how to finish that request(when a ajax request is made I disable all tabs. This is because if a person say loaded up a tab and did not let it finish and tried to go to another tab the same problem would occur with the tabs merging together). Or abort the request and have a screwed up tabs.

Great choices I got. Anyone got any better choices?

Thanks

Bear Bibeault wrote:You need to pass the name of the header you want.



Ya just realized that thanks.
Hi

I am wondering how do I get GetRsponseHeader when I do Jquery Ajax.Complete, or ErrorCallback

I tried something like this

$().ajaxComplete(function(event, XMLHttpRequest, ajaxOptions)
{
var test = XMLHttpRequest.getResponseHeader();
alert(test);
});

but I just get an exception so I am not sure how to grab it.

Bear Bibeault wrote:http://docs.jquery.com/Plugins/livequery



Hmm I still not sure how to get it to work with jquery plugins.

Like I have a color picker

So it looks like this to bind it regularly



so I tried



but these do not work so I am not sure how to do it.

Thanks

Bear Bibeault wrote:Check out the LiveQuery plugin.



Hmm I can't seem to find any examples show how to do it on plugins.

Bear Bibeault wrote:I've used both, but I tend to use the "live" approach unless I have a good reason not to.



Ok

I will try this way and see how it goes.

So how do I do this "....But that's where a match handler comes in handy. "?

Bear Bibeault wrote:

Michael Hubele wrote:I don't know I just thought for some reason that all contents from that tab is destroyed on a click of a new tab.


The HTML for a tab is replaced when you click the tab a second time. But that won't "replace" any script -- script isn't part of the DOM. Once script is loaded into the page, it's there for the life of the page.

By the way, using Firebug for Firefox let's you observe exactly what's going on with the DOM.

So I your saying to take all my plug in scripts and custom scripts from all my tabs(4 tabs in total) and put them all in my main html page and then change all my events to "live"?



yeah, pretty much. I also make use of the LiveQuery plugin's match handlers.

I read some forum post saying using too many of them can slow down your site but I never looked into it and I am not sure what this person meant by many



Me either. It does require some heavy-duty processing -- but I've never noticed any performance degradation as a result.

Also how does that work for things that require binding of plugins. Like I use for instance a color picker on my site. How do I make that use "live"?


You can't. But that's where a match handler comes in handy.

As for the second way I don't know how I could make something that looks to see if it is loaded up or not.






So you still recommend the live way?

Bear Bibeault wrote:I think you might be confusing the way that the Ajax tabs work with the way that iframes work.

When jQuery makes the Ajax request for a tab's contents, that content is not loaded into a separate window the way that it would be with an iframe. Rather, whatever is fetched from the server as the response is simply loaded into the current DOM and becomes part of the same page.

So yes, if the response contains script, it will be executed on the same page multiple times.

I do hope that your tab responses aren't full HTML pages, are they? They should be HTML fragments suitable for placement within the page.

You can do one of two things:

  • Pre-load all scripts that the tab contents will need in the "main" page so that they're there when the tabs get loaded. This is what I tend to do, and the .live() method is essential for this.
  • Put logic in the scripts to detect whether they've already been loaded, and skip re-defining anything if so.



  • Ya probably. I don't know I just thought for some reason that all contents from that tab is destroyed on a click of a new tab.

    No I don't use Full Page Html. I have one main page that contains the html tags like <html>, <body> and in this I have all tabs that has links to my Asp.net MVC controller views. When the tab is clicked it contacts the server and the server returns PartialView(with all html code that is needed for this tab).

    This PartialView currently contains all the needed scripts for this page and it might call other PartialView that I house other html code that is common to my pages on my site(to reduce duplicate code).


    So your saying to take all my plug in scripts and custom scripts from all my tabs(4 tabs in total) and put them all in my main html page and then change all my events to "live"?

    I used "live" only a bit but I know it is used for controls that you will add dynamically will get binded even if the script has run. I also thought I read some forum post saying using too many of them can slow down your site but I never looked into it and I am not sure what this person meant by many. Also how does that work for things that require binding of plugins. Like I use for instance a color picker on my site. How do I make that use "live"?

    As for the second way I don't know how I could make something that looks to see if it is loaded up or not.

    Thanks.
    Hi

    I am using Jquery U.I tabs as a plugin to my site. I thought because I am using them as ajax content that after each time a person clicks on the tab that the previous tab is destroyed not hidden.

    So right now when a user clicks on one of my tabs it calls up some files to be loaded up. In these files there are custom jquery javascript files plus jquery plugin I am using. So everything loads up and all is well when the user clicks on a tab.

    Now if the user clicks on another tab all the scripts are loaded up for that tab. Now if the user comes back a tab they previously clicked on then all those scripts get reloaded up again and this screws up my site. Since anything they do will happen X amount of times where X is how many times they clicked on that tab.

    If they loaded up the tab 10 times and the scripts where loaded up 10 times. Every request they do to the server, or anything popup they click will happen 10times. I do not want this.

    I am not sure what to do. I tried to put caching enable caching for the tabs to stop this but there are some times where I need to reload a tab up. Like for instance Tab A has settings that effect Tab B. If the user changes something in Tab A and then loads up Tab B then Tab B should be re-requested again. But I do not know how to do this and this probably will recreate my old problem of the scripts be reloaded up again.

    So I have no clue where to put them. I do not think I can put them on page load since most of the controls would not exist at this time and binding would not happen.

    Thanks

    Bear Bibeault wrote:Probably not what you wanted to hear, but it's probably time to break open the plugin code and see what it's doing...



    Well I wont' have to do that at least. I set my method to return "false" instead of

    return false;

    and that did the trick. It seems that if you return false; it sends back "False" not "false" and jquery.validate only understand "false".

    Bear Bibeault wrote:Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

    You can go back and change your post to add code tags by clicking the button on your post.



    Sorry was in a rush totally forgot about them. Thanks for reminding me


    Bear Bibeault wrote:I haven't used the remote rule yet myself. Are you sure it's kicking off the check?



    Well I put a debug line in Visual studios on the "Test" Method. When I leave the the "UserName" box it goes to this "Test" method and walks through the debug line. So I am assuming the rule is getting set properly since that's the only piece of code that is referencing the that "Test" method. Firebug also shows in the console that it hits that method and returns "False"

    Hi

    I am not sure what I am doing wrong I am using the Jquery.Validate plugin and it has a remote field

    so I did this


    the required works fine. It's the remote. I am using asp.net mvc and the path is right it hits my method




    it returns false according to firebug yet jquery.validate does not kick in. I am using Version 1.5.5 of jquery.validate and jquery 1.3.2

    What did I miss?

    P.S what is the default message for remote?

    Eric Pascarello wrote:Most people merge files together with their Maven/Ant builds.

    What is a CName? Basically a sub domain.

    And I would say your real problem is that 60 extra seconds it takes to render your JavaScript.

    Eric



    Ok I will have to look at that and how to do that Ant and stuff with .net.


    Well if I compress the files would that no make it render faster. Like I don't know how I could make code more efficient since like 80% of the stuff is like plugins and I know I can't make them more efficient.

    Eric Pascarello wrote:There are many factors that cause load times to be slow.

    First thing I would do is figure out if it is really the downloading of the files that is taking forever or is it the actual rendering of the JavaScript. How can you tell? Run something like no script and see how long the page takes.

    You should probably combine the files into fewer files. Means less http requests. You should also at a minimum remove the comments and whitespace from the JS/CSS files. Look into optimizing any images. Make sure you are not using spacer images or any useless image file.

    Load your JavaScript files from CNames.

    Look at the YSlow plugin for Firebug.

    Eric



    ok while running no script with sloppy @ 56k speeds it takes 40seconds to load up and with scripts 100seconds. So ya it is eating up quite a bit of time.

    So any programs that can merge the files together so on development I still have separate files?

    What is is CNames?