Error(uncaught exception: out of memory) when I do a Ajax Call and Form Post inside JS
I understand there is a solution in jquery to use event.preventdefault but I'm constrained with the limitation I have with the current structure. There is an onclick link that calls the "selectQuery" function and then it goes through the Ajax before posting. If I comment out "f.post",
the ajax runs smoothly otherwise it throws an error:out of memory
Is there a hack or workaround, I can use inside SelectQuery method where it will work similar to event.preventdefault. I tried return false; that didn't work. I 'm thinking we need to have a separation of duties between ajax call and form submit,
if I can have an jquery onclick events inside SelectQuery where I can use event.preventdefault or something.
please advise.
<a href="#" onclick="SelectQuery(2);"><font face="Tahoma" color="#668cd9" size="1"><strong>Query52620161048</strong></font></a>
(this link is generated in code behind)
- function SelectQuery(fid) {
-
- var oform = self.parent.document.getElementById("FormList");
- var TType = self.parent.document.getElementById("TicketType")
- for (i = oform.options.length - 1; i >= 0; i--) {
- oform.remove(i);
- }
- var process = "true";
- var sGlobalID = document.getElementById('GlobalID').value;
-
- $.ajax({
- type: "POST",
- url: "Fields.aspx/GetForm",
- data: JSON.stringify({ sGlobalID: sGlobalID, TicketType:2 }),
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (response) {
- process = "true";
- var forms = response.d;
- $('#output').empty();
- $.each(forms, function (index, form) {
- var opt = document.createElement('option');
- opt.value = form.FormID;
- opt.innerHTML = form.FName;
- oform.appendChild(opt);
- });
- },
- error: function (err) {
- alert("FAIL");
- // alert(err.d);
- },
- failure: function (msg) {
- $('#output').text(msg);
- }
- });
- var GlobalID = document.getElementById('GlobalID').value;
- var f = document.getElementById('FormFields');
- f.action = "Fields.aspx?READQUERY=YES&fid=" + fid + "&sUser=ssy&GlobalID=" + GlobalID;
- f.target = "_self";
- f.submit();
- return (true);
-
- }