I have an issue with a jQuery ajax call. If I comment out the ajax call, it is works. It is passing all the validations and going to else which have ajax call. if i put some alert by commenting ajax call, it is working fine and showing the alert.
error in console : Uncaught RangeError: Maximum call stack size exceeded.
JavaScript
x
152
152
1
function submit() {
2
var companyname = $('#companyname').val();
3
var fname = $('#fname').val();
4
var username = $('#email').val();
5
var countrycode = $('#country-code').val();
6
var mobile = $('#mobile').val();
7
var captcha = $('#captcha').val();
8
var countryid = $('#country-list').val();
9
var ctype = $('#ctype').val();
10
console.log(companyname);
11
console.log(fname);
12
console.log(username);
13
console.log(countrycode);
14
console.log(mobile);
15
console.log(captcha);
16
console.log(countryid);
17
console.log(ctype);
18
if(companyname == '') {
19
Swal.fire({
20
title: 'Enter Company Name',
21
width: 500,
22
padding: '1em',
23
background: '#fff',
24
backdrop: `
25
rgba(0,0,123,0.4)
26
left top
27
no-repeat
28
`
29
})
30
} else if(fname == '') {
31
Swal.fire({
32
title: 'Enter Admin Name',
33
width: 500,
34
padding: '1em',
35
background: '#fff',
36
backdrop: `
37
rgba(0,0,123,0.4)
38
left top
39
no-repeat
40
`
41
})
42
} else if(username == '') {
43
Swal.fire({
44
title: 'Enter Admin Email',
45
width: 500,
46
padding: '1em',
47
background: '#fff',
48
backdrop: `
49
rgba(0,0,123,0.4)
50
left top
51
no-repeat
52
`
53
})
54
} else if(countrycode == '') {
55
Swal.fire({
56
title: 'Select Country Code',
57
width: 500,
58
padding: '1em',
59
background: '#fff',
60
backdrop: `
61
rgba(0,0,123,0.4)
62
left top
63
no-repeat
64
`
65
})
66
} else if(mobile == '') {
67
Swal.fire({
68
title: 'Enter Admin Mobile',
69
width: 500,
70
padding: '1em',
71
background: '#fff',
72
backdrop: `
73
rgba(0,0,123,0.4)
74
left top
75
no-repeat
76
`
77
})
78
} else if(captcha == '') {
79
Swal.fire({
80
title: 'Enter Captcha',
81
width: 500,
82
padding: '1em',
83
background: '#fff',
84
backdrop: `
85
rgba(0,0,123,0.4)
86
left top
87
no-repeat
88
`
89
})
90
} else if(countryid == '') {
91
Swal.fire({
92
title: 'Select Country',
93
width: 500,
94
padding: '1em',
95
background: '#fff',
96
backdrop: `
97
rgba(0,0,123,0.4)
98
left top
99
no-repeat
100
`
101
})
102
} else {
103
$.ajax({
104
type: "POST",
105
url: "<?php echo base_url(); ?>Home/createcsoorpartner_submit",
106
data: {
107
companyname: companyname,
108
fname: fname,
109
countryid: countryid,
110
mobile: mobile,
111
email: email,
112
countrycode: countrycode,
113
captcha: captcha,
114
ctype: ctype,
115
},
116
success: function (data) {
117
resultObj = $.parseJSON(data);
118
console.log(resultObj);
119
if(resultObj.result == "success") {
120
Swal.fire({
121
title: resultObj.msg,
122
width: 500,
123
padding: '1em',
124
background: '#fff',
125
backdrop: `
126
rgba(0,0,123,0.4)
127
left top
128
no-repeat
129
`
130
}).then(function (result) {
131
if (result.value) {
132
window.location = "<?php //echo base_url(); ?>Home";
133
}
134
})
135
} else {
136
Swal.fire({
137
title: resultObj.msg,
138
width: 500,
139
padding: '1em',
140
background: '#fff',
141
backdrop: `
142
rgba(0,0,123,0.4)
143
left top
144
no-repeat
145
`
146
})
147
}
148
}
149
})(1);
150
}
151
}
152
Advertisement
Answer
The error you get is one that $.ajax
will generate if you try to pass a structure that has circular references in it.
If the data definition type is incorrect, the data cannot be successfully sent to the background. The background does not receive the data, the front end will always sent, and this loop causes the stack to overflow.
So all you have to do is keep in check that the parameters you are sending in ajax are right.