468,244 Members | 2,047 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,244 developers. It's quick & easy.

From is going to submit even i keep return false in ajax

Hi, This is prashanth kumar.
I am getting error , i am gettign number of records using ajax. Please solve this

if n >0 i am putting return false in response function.

but form is going to submit. i have no idea where to put retur false, using ajax.

my code is like ,

function checkValid(frm)

if(!checkValidNull(vCourseName,"Please Enter Course Name"))
return false;
if(!checkValidNull(vCourseCode,"Please Enter Course Code"))
return false;
if(!checkValidNull(dFee,"Please Enter Fee"))
return false;

var tmp_collegeId="";
var tmp_deselect="";

}else tmp_deselect+=frm.iCollegeId[i].value+',';

var len=tmp_collegeId.length;
var len1=tmp_deselect.length;

if(frm.mode.value=='Update' && tmp_deselect !='')
getCollege(frm.iCourseId.value,tmp_deselect);//here i am calling function for ajax


function getCollege(iCourseId,tmp_deselect)
var url =admin_url+"check_instructor.php?iCourseId="+iCour seId+'&tmp_deselect='+tmp_deselect;
var isWorking = false;
if (!isWorking)
//catID = course;
isWorking = true;
//url += catID;
if (window.XMLHttpRequest)
http_state_Member=new XMLHttpRequest()
http_state_Member.open("GET",url, true);
http_state_Member.onreadystatechange=handleHttpRes ponseStateMember


// code for IE
else if (window.ActiveXObject)
http_state_Member=new ActiveXObject("Microsoft.XMLHTTP")
if (http_state_Member)
http_state_Member.open("GET",url, true);
http_state_Member.onreadystatechange=handleHttpRes ponseStateMember

//return false;
}//end if(!working))
//if(!displayPopup) closeLoadingWindow(winObj);
}//end functiongetStateName()

function handleHttpResponseStateMember()
var temp;
var tmp_color;//alert(http_state_Member.readyState);
if (http_state_Member.readyState == 4)
var xmlDocument = http_state_Member.responseXML;
var no = xmlDocument.getElementsByTagName('tot').item(0).fi rstChild.data;
alert("Please Change the Instructor Details First ,Which are using Deselected Colleges ");
return false;


Jun 27 '07 #1
1 1303
16,027 Expert Mod 8TB
In Ajax, the request is made and then it goes about its business. When the response returns, then your handleResponse function will run. In the meantime, the form has already been submitted.

To avoid this, keep this Ajax function out of the validate function which you're probably running onsubmit. I am assuming that iCollegeID is a set of checkboxes, so you could check for this when a checkbox is clicked. Alternatively, just check for this on the server-side.
Jun 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by |-|erc | last post: by
10 posts views Thread by ljlolel | last post: by
15 posts views Thread by tshad | last post: by
6 posts views Thread by Stanimir Stamenkov | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.