I have an ajax and full request in the same form. A mouse click fires the ajax in the input field and if I press enter on the same input field right after the mouse click then a nasty error pops up which is shown below.
"The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons."
In my case the input field is a radio button which uses ajax. Pressing enter is causing a full request. I used BalusC's Javascript function which has event.stopPropagation() which worked for me and it was for a text input field. It also worked for a drop down list. But the same event.stopPropagation() is not working for a radio button. You can check BalusC's answer for reference.
Below is my piece of code which doesn't seem to work
<h:form id=blah...... onkeypress="enterToChange(event)">
....
</h:form>
The Javascript function
function enterToChange(event){
if (event.keyCode==13 && event.target.id.match('radiobutton_id'){
event.stopPropagation(); // Don't bubble up.
event.preventDefault(); // Prevent default behaviour (submitting the form).
event.target.onchange(); // Trigger onchange where key was actually pressed.
}
}
I used firebug to see that the statements in the if clause are executed but the error still pops up for some reason and immediately the whole page is rendered. I need to avoid the error in any case.
Any answer is highly appreciated. Thanks
Enter is bound to submit. So if the event keyCode is 13 and event target id matches that of the radio button, then the onclick event for the submit button should fire a JS function which returns false.