I have a simple page to pass a set of data to a a web service through jquery ajax call. The code for web service resides on the same page. The strange problem I have, is that from time to time, it appears that the parameters passed to web service appears
to be mixed up from another session. the web service parameters are firstname, lastname and email address. the data is stored in the database and an email is sent to the email address through the web service. The problem is that from time to time, the email
is sent to the wrong email address from another session but all the firstname and last name is correct!! Am I doing anthing wrong? Below is the code
The jquery call is
<script type="text/javascript">
function CreateQuote() {
var firstname = document.getElementById("FirstNameTextBox").value;
var lastname = document.getElementById("LastNameTextBox").value;
var emailaddress = document.getElementById("EmailTextBox").value;
if (!isValidEmailAddress(emailaddress)) {alert('Enter a valid Email Adress');return; }
var params = "{'FirstName':'" + firstname + "','LastName':'" + lastname + "', 'Email':'" + emailaddress + "'}";
$.blockUI();
$.ajax({
type: "POST",
url: "page.aspx/SaveStuff",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success:
function (msg) {
$('#Result').html(msg.d);
$.unblockUI();
$('#result').show();
$('#result1').show();
},
error:
function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
$.unblockUI();
}
});
}
The web service method on the page is
[WebMethod]
public static string SaveStuff(string FirstName, string LastName, string Email)
{
..... save stuff to database
string EmailResult = CM.SendMail(Message, Email, "Your Latest message", "VVV@XCC.com");
}
string resultMessage = "<h3>Created on " + DateTime.Now.ToString()+"</h3>";
return resultMessage;
}
Theguzu
Member
77 Points
139 Posts
JQuery Web Service Call grabs value from another session!!!!!
Feb 15, 2012 02:01 PM|LINK
I have a simple page to pass a set of data to a a web service through jquery ajax call. The code for web service resides on the same page. The strange problem I have, is that from time to time, it appears that the parameters passed to web service appears to be mixed up from another session. the web service parameters are firstname, lastname and email address. the data is stored in the database and an email is sent to the email address through the web service. The problem is that from time to time, the email is sent to the wrong email address from another session but all the firstname and last name is correct!! Am I doing anthing wrong? Below is the code
The jquery call is
<script type="text/javascript"> function CreateQuote() { var firstname = document.getElementById("FirstNameTextBox").value; var lastname = document.getElementById("LastNameTextBox").value; var emailaddress = document.getElementById("EmailTextBox").value; if (!isValidEmailAddress(emailaddress)) {alert('Enter a valid Email Adress');return; } var params = "{'FirstName':'" + firstname + "','LastName':'" + lastname + "', 'Email':'" + emailaddress + "'}"; $.blockUI(); $.ajax({ type: "POST", url: "page.aspx/SaveStuff", data: params, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { $('#Result').html(msg.d); $.unblockUI(); $('#result').show(); $('#result1').show(); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); $.unblockUI(); } }); }The web service method on the page is
[WebMethod] public static string SaveStuff(string FirstName, string LastName, string Email) { ..... save stuff to database string EmailResult = CM.SendMail(Message, Email, "Your Latest message", "VVV@XCC.com"); } string resultMessage = "<h3>Created on " + DateTime.Now.ToString()+"</h3>"; return resultMessage; }tanatrajan
Participant
1784 Points
370 Posts
Re: JQuery Web Service Call grabs value from another session!!!!!
Feb 15, 2012 02:35 PM|LINK
in your $.ajax(....
calls pass parameter
async=false