Welcome Guest, Not a member yet? Register   Sign In
need php ajax framework like this:
#1

[eluser]FutureKing[/eluser]
I work with jquery for making ajax requests. But for simple CURD app I have to write a lot of jquery javascript.

Is there any php framework that I can use like this:
Code:
<?php
$ajax= new $ajaxForm();
$ajax->Form(
?>

<form action="process.php" method="post">
<input type="text" id="txt_name"/>
<select id="dd_list"/>
    <option value="1"></option>
    <option value="2"></option>
</select>
&lt;input type="button" id="btn_submit" value="Submit" /&gt;
&lt;/form&gt;

<onSuccess>
//do something
</onSuccess>
<onFail>
//do something
</onFail>

&lt;?php ); ?&gt;
&lt;?php $ajax->submitButton('btn_submit'); ?&gt;
&lt;?php $ajax->postForm(); ?&gt;

In the above code the postForm method does the following:

--&gt; gets all the html between "(" and ")".

--&gt; finds ids of controls,form action,methods etc

--&gt; now generates jquery according to the ids,form action etc.

--&gt; does the ajax request to process.php.


I have written this code to show you what I want. Is there something like this available.

If not then if I want to write library for this what chapters of php should I read?
#2

[eluser]jayrulez[/eluser]
yes i know 1 that can do something like that
#3

[eluser]FutureKing[/eluser]
[quote author="jayrulez" date="1245221175"]yes i know 1 that can do something like that[/quote]
then tell me the name and link
#4

[eluser]slowgary[/eluser]
Why not just write the javascript to seek out all the form values instead? Then you could just pass the form ID and the server-side URL to the javascript and it could do everything else for you.
#5

[eluser]FutureKing[/eluser]
[quote author="slowgary" date="1245225281"]Why not just write the javascript to seek out all the form values instead? Then you could just pass the form ID and the server-side URL to the javascript and it could do everything else for you.[/quote]

Yes, Currently I do write js for Ajax. But there are alot of ajax code in my project and it is not easy to mantain that code.

For making ajax request I have to write the following code additionaly


$('document').ready(function(){
name=$('#txt_name').attr('value');
list=$('#dd_list').attr('value');
$.post('process.php',{ name: name, list:list },function(data){

});
});

This code is very small because there are very few form controls.
When form becomes big then A lot of code has to be written.
The situation become more difficult when there are many forms.

The approach I shown above is looks very simple. Is there something like above php code available?
However I have started working on it.
#6

[eluser]slowgary[/eluser]
Yes, I understand that. I'm suggesting that instead of using a PHP library to create JavaScript, you should just write some JavaScript that gathers all the data from the form and puts it into an AJAX request. Basically, since the AJAX happens clientside, you should let the clientside deal with the form library. This way, your server side doesn't have to spend time creating code that the client may not take advantage of.

This guy seems to have created a plugin to do just this: http://malsup.com/jquery/form/

It gathers all the 'name' and 'value' attributes and submits them to the form's 'action' attribute. Basically, your server side just produces a normal form and the plugin turns it into ajax. If the user has disabled JavaScript, the form acts like a normal form.
#7

[eluser]FutureKing[/eluser]
thanks. I am checking.




Theme © iAndrew 2016 - Forum software by © MyBB