Jump to content

this jquery works with coldfusion but not php, help please


zimminy

Recommended Posts

I worked with PHP for several years, then have worked for the last 2 with Coldfusion.

I do the following in coldfusion and tried the same type of thing in PHP, but PHP does not return proper results.
Does anyone know how I can make this work in PHP? Any tips/help VERY much appreciated, I an my daughter have a lot of coding work waiting for this answer!
Neither one of us can figure this out.



Coldfusion example:

//in the javascript/jquery section of the page:
function getOrders(customerid){
    $.get('scripts/orderrequests.cfc?method=getOrders&custid='+customerid,
        function(data){
            document.getElementById('orderdiv').innerHTML = data;
        }
    );
}



then further down on the page

<a href="javascript:getOrders(#customerid#)">Click here to list all of your orders.</a><br>
<div id="orderdiv"></div>

---------
then, briefly... in scripts/orderrequests.cfc  is the coldfusion function that gets the orders out of the database, and returns an entire html table of the orders
<cfunction name="getOrders" ...>
    <cfargument name="custid" required="yes"/>
    <cfquery.... gets the order info out of db just like any mysql query basically...>
    
    <cfsavecontent variable="tableinfox">
        <table>
            <tr><tr><td>#orderid#</td><td>#orderdate#</td></tr></table>
        </table>
    </cfsavecontent>

    <cfreturn tableinfox/>
</cfunction>
-------------------

The scenario beautifully loads the order data into the div "<div id="orderdiv"></div>" above.
Been using this for two years in coldfusion, and I would LOVE to figure out how to do the same scenario in PHP, so I tried..

function getOrders(customerid){
    $.get('includes/gettheorders.php?custid='+customerid,
        function(data){
            document.getElementById('orderdiv').innerHTML = data;
        }
    );
}
<?php
echo '<a href="javascript:getOrders('.$customerid.');">Click here to list all of your orders.</a><br /><div id="orderdiv"></div>';
?>
Then, "includes/gettheorders.php" is just a simple php query that loads the orders into a table...outputs it to it's own page, which then should be returned as that "data" in function(data)... and loaded into the div.. "document.getElementById('orderdiv').innerHTML = data;"

When I tried this with various code on "gettheorders.php", the best I can do is that, "gettheorders.php" can return ONE number "3" but not "content" like an HTML table full of content..
What do I need to do to make this kind of scenario work in PHP? I obviously want to return more content than just a number.

 

I am so hungry for this answer, you  don't even know.. but then you are programmers who have also banged your head against your desk, so I guess you do!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.