0

Hi all I am stuck trying to figure out the best way to get data as at the moment I have tried a few different ways to achieve this with no luck.

What I am trying to do is update a block of php code that is in my sidebar when I submit a button.

I have tried loading a file with ajax but because I am using the smarty template it loads the file but the
php code does not run.

I have managed to get it to work to a certain point but it has to refresh the page which is not what I am after
as firefox post a pop up alert saying the page needs reloading and also it resets the page that had previous data already loaded.

Does anyone know a better way to acheive this.

2
Contributors
2
Replies
6
Views
4 Years
Discussion Span
Last Post by mbhanley
0

It might help to post some code, but the most likely reason is an error with the callback function in your ajax call.

0

The code I have so far submits to add a domian name to the cart which is on another page.

The problem is I am using Smarty Template and when the page I want the php code to update will not update unless I refresh the page.

And I cannot use ajax to request the page because I tried that and the php code did not run I just got a load of code that the Smarty template could not translate.

This bit of code gets an array from a session and echos the domain names added to cart.

{php} 
for ($i=0; $i<=10; $i++) {
$doms  = $_SESSION['cart']['domains'][$i]['domain'];
echo $doms, "<br />";
}
{/php} 

This code submits a domain name to add to the cart.

{literal}
<script type="text/javascript"> 
$(function(){
    $("#domainorder").submit(function(e){    
       e.preventDefault();
        $.post("cart.php?a=add&domain=register", $("#domainorder").serialize(),
        function(data){}, "json");  
                                }); 
                                return false;
    });
$(document).ajaxStop(function(){
    window.location.reload();
});
</script>
{/literal}

Once the above code runns it does the job but refreshes the page, idealy I need to not refresh the page but just the php code above all on the same page so it updates the domain names that are in the cart.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.