i am trying to clean up my code.. is there a way to run this code with Ajax or jquery rather than placing the code in the html page itself..thanks in advance
<?php $acct = new acct; echo $acct->accountProfile("accountphone"); ?>
i am trying to clean up my code.. is there a way to run this code with Ajax or jquery rather than placing the code in the html page itself..thanks in advance
<?php $acct = new acct; echo $acct->accountProfile("accountphone"); ?>
You can have js execute an ajax function (via $.post
) on a load event like $( document ).ready(function() {//code}
, using something like $("#div").html(data);
to populate data into a container.
That said, I don't think that's necessarily more organized than putting it into your HTML code itself. You don't want to process LOGIC too much in your view, but the nature of web development is that it is "messy" (IMO) and that you have to often just insert PHP all over the place, to do singular functions/echos as you seem to be doing.