Hi, I have a form with too many fields. What I am trying to do, is first do some validation using jquery; which is working fine so far. I have an event handler "onclik" which validate the file type that uploaded by the users, and if the file is not image shows a message to the user. If the file is good it should send some data to the server and wait for the response. So far everything is working fine for me, but the ajax doesn't work. Please give me hand Here is my code:
$(document).ready(function(){
//$(\'#saveData\').bind(\'click\', function() {
//$(\'#saveData\').live(\'click\', function() {
$(\'#saveData\').click( function(){
var ext = $("#articlePhoto").val().split(".").pop().toLowerCase();
var allow = new Array("gif","png","jpg","jpeg","");
if(jQuery.inArray(ext, allow) == -1) {
$("div.fileType").html("some error message");
$("div.fileType").attr("tabindex",-1).focus();
return false;
}
else
{
$.ajax({
type: "POST",
url: url+"somefile.php",
data: "item1=somedata&item2=others",
success: function(data){
alert(data); // doesn't work
}
});
}
});
});
Thanks