javascript - Loading file contains using document ready function not working

36

I would like to load the following page inside another page after the main page has loaded. I have the following code:

<script language="javascript">
    $(document).ready(function(){
        $.get('http://$_SERVER[SERVER_NAME]/X.php?logon=Y&vendorref="<?php .$row_RS_Product['id'].?>"&mode=product', function(data) {
            $('#tabs-6').html(data);
        });
    });
</script>

I am not very familiar with this code so please excuse me if I made the obvious mistake Could anybody help please as it does work when usingfile_get_contents in php, but this is slowing the page load down tremendous. Any help welcome

164

Answer

Solution:

I think you want to get$_SERVER[SERVER_NAME] from PHP so you need to add<?php echo when creating the url to get from. Also you need to haveecho when opening the php tag to echo, not. . Dot is used to concat string in php like this"aaa" . "bbb" (without opening the php tag)

So you need something like this:

$.get('http://<?php echo $_SERVER[SERVER_NAME]; ?>/X.php?logon=Y&vendorref="<?php echo $row_RS_Product['id']; ?>"&mode=product', function(data) {
        $('#tabs-6').html(data);
    });

People are also looking for solutions to the problem: all data type in PHP PDO query to ms access are strings? Need help to retrieve numeric types

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.