SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict Shaydez's Avatar
    Join Date
    Jul 2006
    Location
    Boca Raton, Florida
    Posts
    356
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Ajax Troubleshooting

    i'm just getting into custom coding in ajax.. fun as hell by the way..

    my current problem is i don't know what exactly is getting passed through httprequests. is there a firefox tool that shows what is getting passed?

    also... can i put php script into javascript?

    i have 2 methods going on .. i wanted to test if php will work in the javascript.. other method is just to grab the id from a hidden value.

    Code JavaScript:
     
     
    function showprice(str, prodID)
    {
     
    var str=document.CalculateForm.txtqty.value; 
    var prodID=document.CalculateForm.txtprodID.value; 
     
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("totalit").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","/getprice.php?q="+str+"pid="+<?= $productID; ?>,true);
    xmlhttp.send();
     
     
    }
    Sr. Website Developer and Internet Marketing
    www.CarlosJa.com Note: If anyone
    needs to get ahold of me please feel free to email me through
    my site. Apparently i missed quite a few private messages.

  2. #2
    SitePoint Enthusiast nimpkish-media's Avatar
    Join Date
    Jun 2010
    Location
    Victoria BC, Canada
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use jQuery as my JS library... if you are interested you can take a look at their AJAX methods.

    http://api.jquery.com/category/ajax/

    They are well documented and easy to use.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •