cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: cURL speed problem

From: Colleen R. Dick <platypus_at_proaxis.com>
Date: Thu, 09 Feb 2006 09:20:32 -0800

I cant answer your cURL speed problem, it could be network latency or it
could just be your XML results are big. But I can help you make your
users suffer less with it.

Here is my code to display an animation while a bunch of stuff gets
ready. This is a smarty template but you could do the whole thing in
php/html. The first block checks if the jst is set, if not, it
immediately creates a form that posts the jst var to the same page and
uses javascript to submit it. This ensures that if javascript is
disabled, none of this clientside stuff will set up and they will just
have to wait for the page to lode.

The second block checks if jst is on, if so it renders the hidepage div

The main block attribute is set to invisible if the jst is on, otherwise
block.

once the page is finished , it will arrive at the bottom and execute the
javascript at the bottom. This javascript that will hide the animation
div and restore the main div to visible.

-------------
{if $jst == "" }
<form name="jstest" action="{$url}/mypage.php" method="post">
<input type="hidden" name="js" value="on" />
<!--whatever else you need to post to the page -->
</form>
<script type="text/javascript">
<!--
document.jstest.submit();
//-->
</script>
{/if}

{if $jst == 'on' }
<div id="hidepage" align="center">
<img src="{$imgurl}/pageloadbar.gif" alt="page load animation" /><br/>
Please wait while the data fills in
</div>
{/if}

<div id="main" style="display: {if $jst == 'on'}none{else}block{/if};">
<!-- here goes all your main stuff -->
</div>

<script type="text/javascript">
x=document.getElementById('hidepage');
x.style.display = "none";
x=document.getElementById('main');
x.style.display = "block";
</script>

On Thu, 2006-02-09 at 03:48 -0800, Nick Papanikolaou wrote:
> Hi everyone. I am building a website that performs
> some requests to another server, retrieves the
> information and then displays it. The requests are
> made with XML files that are dynamically created from
> my page. My website works like this:
>
> There is one page with a form where the user must
> enter the search criteria. Then the form posts the
> user entered data to another webpage.
>
> The second webpage puts them into an XML, posts it
> using cURL and stores the response into a string
> variable. The variable then is parsed with PHP’s
> simple XML and echoes them.
>
> The problem is that went the second page loads, the
> status bar say that the page is loaded while the page
> seems blank. After a while the page starts to load
> again and the displays the retrieved data. I tried to
> find out why this happens and I erased everything
> except from the XML that is posted and the cURL code
> that posts it and assigns the response to a variable,
> so I came up with the conclusion that cURL is
> responsible. The XML that I send is about 15 to 20
> lines long and it’s well formatted so I don’t think
> the XML is the problem, but the response XML might be
> huge depending on the search data entered.
>
> Can anyone tell me how to fix this problem or how to
> display a “Loading…” or something while the page seems
> blank? I’m sorry for the huge post. Thanks in advance!
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-02-09