Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    49
    Thanks
    14
    Thanked 0 Times in 0 Posts

    echo a php file in javascript .innerHTML

    Hi all,

    Absolute javascript novice here. Just in the process of redesigning a part of our website and it was previously made using javascript by a previous employee. I have no knowledge of javascript just php. I have managed to get everything working in the new design except for I am trying to echo a php file in a .innerHTML part of javascript and am having no look.

    All the php file does is echo's a div with some information(cart total and items amount)

    the php file i am trying to echo is /club-shops2/php/update-cart-div.php

    Javascript code is below:

    Code:
    var params = "club_id="+club_id+"&size_id="+size_id+"&product_id="+product_id+"&quantity="+quantity;
    xmlhttp.open("POST", "/club-shops2/php/add-to-cart.php", true);
    document.getElementById("details").innerHTML = "update me";
    Anyone have any ideas what i put in the "update me" to echo the php file?

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Assuming that you've manually started your XHR, after the xmlhttp.open() command should be the xmlhttp.send(), which will process the page, then you need the xmlhttp.responseText as the innerHTML IF the statusResponse is good.

    Also, you set params (which I assume are for the GET / url params) but don't include them?
    Last edited by WolfShade; 03-20-2013 at 03:53 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    49
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Assuming that you've manually started your XHR, after the xmlhttp.open() command should be the xmlhttp.send(), which will process the page, then you need the xmlhttp.responseText as the innerHTML IF the statusResponse is good.

    Also, you set params (which I assume are for the GET / url params) but don't include them?
    I'll have a google for those, not really sure what they mean as i don't know javascript(only know basic php)

    and as per my previous post it was a previous employee that made all the javascript, i know pretty much nothing about it unfortunately so not quite sure about the params

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Here is a good start for understanding XHR. I think the params would be part of the send (ie, xmlhttp.send(params)).
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

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