ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

async Request

December 30, 2009 4:19pm

Subscribe [1]
  • #1 / Dec 30, 2009 4:19pm

    rebeccaod

    20 posts

    For our website, we have a site search and when we started designing it, we split it up into two different searches because

  • #2 / Dec 30, 2009 5:07pm

    rebeccaod

    20 posts

    For our website, we have a site search and when we started designing it, we split it up into two different searches because

  • #3 / Dec 30, 2009 5:11pm

    rebeccaod

    20 posts

    For our website, we have a site search and when we started designing it, we split it up into two different searches because of the large amount of data to search through. We did this by using an asyncRequest (I think its ajax, someone just gave me the code to add) and it has been functioning fine for several months.

    Just today I realized that the code no longer wor

  • #4 / Jan 04, 2010 12:35pm

    Robin Sowell

    13255 posts

    If the regular search form is working, this might be best in ‘How to’- does sound like you’re doing some sort of ajax.  In any case- shifting to ‘How to’- you might want to paste a code block to show how you’re doing the search.  And to start debugging- I’d look for any js errors.

  • #5 / Jan 04, 2010 2:47pm

    rebeccaod

    20 posts

    We have created a search on our website, but the data is so large that we are searching through that we have added a second s

  • #6 / Jan 04, 2010 2:57pm

    rebeccaod

    20 posts

    We have created a search on our website, but the data is so large that we are searching through that we have added a second synchronized search that runs though JavaScript and prints out the results later to keep the page from taking too long to load. Just last Monday, we upgraded our ExpressionEngine to v1.6.8 and realized that the async results no longer function. We also have a development site which uses ExpressionEngine version 1.6.0 and the results do function.

    Why would it work on the older rather than newer version and how can I work around this problem?

    [removed]
    var sUrl = "/inc/long_search.php?searchTerm=<? echo $searchTerm;?>&searchRegion;=<? echo $searchRegion;?>&showAllProj;=<?echo $showAllProj;?>&resultCount;=<?echo $resultCount;?>"; 
     
    var div = document.getElementById('projects');
     
    var handleSuccess = function(o){
        if(o.responseText !== undefined){
           /*
            div[removed] = "<li>Transaction id: " + o.tId + "</li>";
            div[removed] += "<li>HTTP status: " + o.status + "</li>";
            div[removed] += "<li>Status code message: " + o.statusText + "</li>";
            div[removed] += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
            div[removed] += "<li>Server response: " + o.responseText + "</li>";
            div[removed] += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
                             " [bar] => " + o.argument.bar +" )</li>";
                             */
            div[removed] = o.responseText ;
        }
    }
     
    var handleFailure = function(o){
        if(o.responseText !== undefined){
            div[removed] = "<li>Transaction id: " + o.tId + "</li>";
            div[removed] += "<li>HTTP status: " + o.status + "</li>";
            div[removed] += "<li>Status code message: " + o.statusText + "</li>";
        }
    }
     
    var callback =
    {
      success:handleSuccess,
      failure: handleFailure,
      argument: { foo:"foo", bar:"bar" }
    };
     
    var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
    
    var newUrl = "/inc/count_search.php?searchTerm=<? echo $searchTerm;?>&searchRegion;=<? echo $searchRegion;?>"; 
     
    var div1 = document.getElementById('projectscount');
     
    var handleSuccess1 = function(o){
        if(o.responseText !== undefined){
           /*
            div1[removed] = "<li>Transaction id: " + o.tId + "</li>";
            div1[removed] += "<li>HTTP status: " + o.status + "</li>";
            div1[removed] += "<li>Status code message: " + o.statusText + "</li>";
            div1[removed] += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
            div1[removed] += "<li>Server response: " + o.responseText + "</li>";
            div1[removed] += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
                             " [bar] => " + o.argument.bar +" )</li>";
                             */
            div1[removed] = o.responseText ;
        }
    }
     
    var handleFailure1 = function(o){
        if(o.responseText !== undefined){
            div1[removed] = "<li>Transaction id: " + o.tId + "</li>";
            div1[removed] += "<li>HTTP status: " + o.status + "</li>";
            div1[removed] += "<li>Status code message: " + o.statusText + "</li>";
        }
    }
     
    var callback1 =
    {
      success:handleSuccess1,
      failure: handleFailure1,
      argument: { foo:"foo", bar:"bar" }
    };
     
    var request1 = YAHOO.util.Connect.asyncRequest('GET', newUrl, callback1);
    [removed]
  • #7 / Jan 04, 2010 3:18pm

    Robin Sowell

    13255 posts

    The js tends to get chewed up due to security filters.

    Any chance you can link to a working vs. non-working version?  Like I say- first thing I’d do is look for js errors- and track what’s happening via firebug or some such.

  • #8 / Jan 04, 2010 3:37pm

    rebeccaod

    20 posts

    Sure. Here are the links to the search pages.
    http://www.reedconstructiondata.com/search/results/?searchTerm=cars#projects
    http://dev.reedconstructiondata.com/search/results/?searchTerm=cars#projects

    If you’ll notice the projects at the bottom (the links should drop you right to where they should show up), the development site will eventually load the projects, but the production site just keeps running and running. I have tried copying code and changing code and all I can think of as the difference is the different versions of ExpressionEngine.

    I have not seen any errors, and since its the exact same code on both sites, I would think it would show up as an error.

  • #9 / Jan 04, 2010 3:54pm

    Robin Sowell

    13255 posts

    Hrm- look at the rendered source code- particularly:

    var callback =
    {
      success:handleSuccess,
      failure: handleFailure,
      argument: { foo:"foo", bar:"bar" }
    };

    You lose the arguments on the live site.  So something seems to be buggering the js.  Make sure in ‘Admin- System Prefs- Output and Debug’ you have ‘show php errors’ set to show for superadmins.  Suppression of all errors can bork things. 

    What was it set to before- did you have to change it?

  • #10 / Jan 04, 2010 4:19pm

    rebeccaod

    20 posts

    Its fixed! I don’t know why the argument would not work, but I switched it to

    argument:['foo', 'bar']

    and it worked fine. I did keep getting an error message that something was wrong with the { but I couldn’t figure it out. Thank you so much for your help!

  • #11 / Jan 04, 2010 4:35pm

    Robin Sowell

    13255 posts

    Hrm- might be an issue w/the parser not liking the { foo:"foo" }- there is a current bug that should be fixed next release - some code to handle edge cases was goofing up conditionals.  Flipping in an older version of the functions class might have fixed it.  But if you can avoid the curly brackets and have the js working- ‘yay’.  And we’ll avoid the issue entirely 😉.  Glad you got it working- and welcome to the forums!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases