Thread: ajax help pease
View Single Post
  #1  
Old 01-29-2010, 06:02 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default ajax help pease

i need help with this code if theres any Ajax coders on here this is my grabbing script with grabs the content without a page refresh. it was working a charm on vB3 but since i updated to vB4 its not working something to do with it not working on XHTML can anyone help me out PLEASE need to get it back up urgent

Template Code:

HTML Code:
<script type="text/javascript">

    function ax()
    {
        if(document.getElementById('btnS').value=="Fill")
        {
            document.getElementById('txtTitle').value        =    "";
            document.getElementById('image').value        =    "";
            document.getElementById('infolink').value        =    "";
            document.getElementById('summary').value        =    "";
            
            axtitle();
            aximg();
                        axlink();
            axdesc();            
        }
    }

    function axtitle()
    {
        var uri    =    document.getElementById('url').value;

        var xt = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xt)
        {
            xt.onreadystatechange = function()
            {
                if (xt.readyState == 4 && xt.status == 200)
                {
                    document.getElementById('txtTitle').value= xt.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xt.open("POST", "getinfo.php?purl="+uri+"&preq=title", true);
            xt.send("purl="+uri+"&preq=title");
        }
    }
    
    function aximg()
    {
        var uri    =    document.getElementById('url').value;

        var xi = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xi)
        {
            xi.onreadystatechange = function()
            {
                if (xi.readyState == 4 && xi.status == 200)
                {
                    document.getElementById('image').value= xi.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xi.open("POST", "getinfo.php?purl="+uri+"&preq=img", true);
            xi.send("purl="+uri+"&preq=img");
        }
    }

    function axlink()
    {
        var uri    =    document.getElementById('url').value;

        var xi = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xi)
        {
            xi.onreadystatechange = function()
            {
                if (xi.readyState == 4 && xi.status == 200)
                {
                    document.getElementById('infolink').value= xi.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xi.open("POST", "getinfo.php?purl="+uri+"&preq=link", true);
            xi.send("purl="+uri+"&preq=link");
        }
    }
    
    function axdesc()
    {
        var uri    =    document.getElementById('url').value;

        var xd = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xd)
        {
            xd.onreadystatechange = function()
            {
                if (xd.readyState == 4 && xd.status == 200)
                {
                    document.getElementById('summary').value    = xd.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xd.open("POST", "getinfo.php?purl="+uri+"&preq=desc", true);
            xd.send("purl="+uri+"&preq=desc");
        }
    }

</script>

<form>
<table border="0" cellpadding="1" cellspacing="1">
<tr>
    <td>
    <b>Quick Fill:</b><br />  
    <input class="url" type='text' size='40' name='url' id='url' value="" /> <input type='button' id="btnS" value='Fill' onclick="ax(this);" />  
    </td>
</tr>
</table> 

            <div><input class="title" type="text" size="40" id="txtTitle" name="name" value="" /></div>

            <div><input class="url" type="text" maxlength="1000" size="40" name="info" id="info" value="" /></div>

            <div><input class="img" type="text" maxlength="1000" size="40" name="image" id="image" value="" /></div>
</form>
PHP File Code:
PHP Code:
<?php

function get_page($url)
{
    
$ch curl_init();
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_URL$url);
    
$content curl_exec($ch);
    return 
$content;
}

$purl        "";
$preq        "title";
$title    "";
$desc        "";
$imgl        "";

extract($_REQUEST);

if(
$purl!="") {

    
$content get_page($purl);
      
// ###############  GAMESTOP INFO    
 
if(preg_match("~gamestop.com~"$purl))
    {
        
preg_match("~<td width=\"510\" align=\"left\" class=\"prodtitle\" valign=\"top\">.+?(.+?)&nbsp;.+?</td>~s"$content$res);
        
$replacements "/\'/";
        
$titles trim($res[1]);
        
$title strip_tags(preg_replace($replacements,'',$titles));
                
        
preg_match("~<img src=\"(/common/images/lbox[^\"]+)~s"$content$resimg);
        
$img1 strip_tags("http://www.gamestop.com".$resimg[1]."");
        
preg_match("~<td width=\"620\" class=\"stdcopy\">(.+?)</td>~s"$content$resdesc);
        
$replacements "/\'/";
        
$desc strip_tags(preg_replace($replacements,'',$resdesc[1]));
        
$desc trim($desc);
        if (empty(
$desc)) { $desc "No Description Available"; }        
    }


}
 
//$img = cacheFetch($img1,"");

if($preq=="title")
    print(
$title);
else if(
$preq=="desc")
    print(
$desc);
else if(
$preq=="img")
    print(
$img1);    
else if(
$preq=="link")
    print(
$purl);    
?>
--------------- Added [DATE]1264870365[/DATE] at [TIME]1264870365[/TIME] ---------------

* BUMP * can anyone help me with this code please.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01345 seconds
  • Memory Usage 1,830KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete