views:

27

answers:

1

What's better of this two options:

1. $.post( '/ajax/action', function(data) { doResult(); }  );

*This option has to receptors: ajax.php and action.php*

or

2. $.post( '/action', { typerequest: 'ajax' }, function (data) { doResult(); }

*This option has only 1 receptor: action.php (if typerequest exists, returns ajax result)*

Form without ajax looks like:

<form action="/action">
A: 

No difference between those two, really. Pick whatever is easier for you.

I think it is easier to have Ajax scripts handled independently (that is option 1). The other script is going to have to print out a whole page on its own. That means you have to conditionally display it (e.g. by typerequest) and you end up wrapping a lot of stuff in conditionals.

But really either way is fine. Pick whatever you are most comfortable with. Just be consistent.

tandu