So my goal was to have a function in my jQuery code, that allowed me to do case statements that then allowed me to do what I needed with each form, without having to re-type the whole post function.
UPDATE my fix is at the very bottom of this question
e.g.
function fetch(e,formstring)
{
$.ajax({
type: 'POST',
url: 'system/classes/core.php',
data: formstring,
dataType: 'json',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
success: function(data){
$.each(data, function(i, obj) {
switch (e) {
case 1:
$.each(obj, function(key, val) {
alert(key+" - "+val);
});
break;
case 2:
alert("sucker");
break;
case 3:
//LoginSript
$('#rightheader').html(obj.code);
break;
case 4:
//WelcomePage/Signup
$('#window').html(obj.code);
break;
}
});
},
error: function(data){
$.each(data,function(i,myinfo){
alert(i);
});
}
});
return false;
}
While fetching data seems to work, submitting forms seems not.
$(function() {
$("form#login").submit(function(){
shownotify(1,"Please hold we are login you in.");
fetch(1,$(this).serialize());
});
});
I thought I was doing everything right.
just also so you can see here is the show notify function too.
function shownotify(e,msg)
{
if(e==1){$('#notify').show();};
if(e==2){$('#notify').hide();};
$('#notifyheader').html("Please Hold");
$('#notifytext').html(msg);
}
I am wondering if I have an error, or am I doing this wrong?
The way I fixed the error was by setting a setTimeout function around the $(function(){})