Xajax + smarty question _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Xajax + smarty problems. Xajax + smarty is in a hurry! My refreshContent function cannot be called. I have been troubled by this problem for several days. I just cannot find the problem. I hope you can help me to see it. thank you for the xajax + smarty problem! My refreshContent function cannot be called. I have been troubled by this problem for several days, but I cannot find the problem. I hope you can check it out for me. thank you!
The code is as follows:

Xajax_smarty.php

Require_once ('config/Config. inc. php ');
Require_once ('xajax/xajax_core/xajax. inc. php ');
$ Xajax = new xajax ();
Function loadContent ($ n ){
Global $ Smarty;
If ($ n = 0 ){
$ Data [] = array ('title' => 'helloworld', 'content' =>'

What is going on?

');
$ Data [] = array ('title' => 'another item', 'content' =>'

Nothing fancy

');
}
Else if ($ n = 1 ){
Echo '================ ';
$ Data [] = array ('title' => 'dynamically loaded', 'content' =>'

There you go

');
}
$ Smarty-> assign ('posts', $ data );
$ Ret = $ Smarty-> fetch('post.html ');
$ Smarty-> clear_all_assign ();
Return $ ret;
}
Function refreshContent ($ formValues) {// call failed
Echo "ldkfjdl ";
$ Response = new xajaxResponse ();
$ NewContent = loadContent ($ formValues ['Select _ page']);
$ Response-> addAssign ('content', 'innerhtml ', $ newContent );
Return $ response;
}
$ Xajax-> registerFunction ('refreshcontent ');
$ Xajax-> processRequest ();

$ Smarty-> assign ('content', loadContent (0 ));
$ Smarty-> assign ('xajaxjavascript ', $ xajax-> getJavascript ('xajax /'));
$ Smarty-> display('main.html ');
?>

Post.html


<% {Foreach from = $ posts item = post} %>


<% {$ Post. title} %>
<% {$ Post. content} %>


<% {/Foreach} %>



Main.html


<% {$ Xajaxjavascript} %>



Smarty $ amp; xajax




<% {$ Content }%>



Http://www.bkjia.com/PHPjc/632483.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632483.htmlTechArticlexajax+smarty problem urgent Ah! My refreshContent function cannot be called. I have been troubled by this problem for several days, but I cannot find the problem. I hope you can help me to see it. thank you...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.