473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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)
{

with(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="";
for(i=0;i<frm.iCollegeId.length;i++)
{
if(frm.iCollegeId[i].selected){
//alert(frm.iCollegeId[i].selected);
tmp_collegeId+=frm.iCollegeId[i].value+',';

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

var len=tmp_collegeId.length;
var len1=tmp_deselect.length;
tmp_collegeId=tmp_collegeId.substr(0,len-1);
tmp_deselect=tmp_deselect.substr(0,len1-1);
frm.collegeId1.value=tmp_collegeId;

if(frm.mode.value=='Update' && tmp_deselect !='')
{
document.getElementById('submitid').value="";
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;
//alert(url);
if (window.XMLHttpRequest)
{
http_state_Member=new XMLHttpRequest()
http_state_Member.open("GET",url, true);
http_state_Member.onreadystatechange=handleHttpRes ponseStateMember
http_state_Member.send(null)

}

// 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
http_state_Member.send()

}
}
//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(no);
if(no>0)
{
alert("Please Change the Instructor Details First ,Which are using Deselected Colleges ");
return false;

}
}

}
Jun 27 '07 #1
1 1456
acoder
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

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

Similar topics

0
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
15
by: tshad | last post by:
I was looking for a way to handle refreshes (user pressed refresh button) and found a piece of code to check if a Web page was refreshed but I can't get it to work. The code is:...
4
by: d3vkit | last post by:
I have a form on my page, and some javascript which uses ajax to submit the form, and then opens the new page in a div using ajax so there is no refresh. This works fine. But the problem is this: all...
6
by: santhoskumara | last post by:
How to request to servlet from Ajax and also I got the DOM object in the servlet through Business Logic. Now how will i pass the DOM object from serlvet to Clientside. Where in the client Side i am...
6
by: Stanimir Stamenkov | last post by:
I have a form without a submit button like: <form name="form1" action="" onsubmit="alert('submit ' + this.name);"> <div> <label>Field 1: <input type="text" name="field1"...
2
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.