Variable into $.ajax()
Variable into $.ajax()
Hi,
I recently closed a thread related to this accidentally. while the posts helped, I didn't quite solve the problem.
For some reason, the value of variables is not passed along into the the query string. I've tried get and post with no luck. If I hard code the data field then the valus IS added to the query string.
Below is my code
function CallService()
{
name = $("#taYourName").text();
$.ajax(
{
Type: "GET",
contentType: "application/xml",
url: "YourNameIs.asmx/YourName",
data: { yourName: name },
success: function (data) {
SetYourNameMessage(data);
}
});
}
If I change data to: data: "yourName=Nick" or even just append that to the url, it works fine. Something about those locally declared variable.
2. Secondly, in my success function, I don't know how to access the response text. When I debug the data parameter I can see the return from my web service in the second child of the data. But data[1] is undefined.
Thanks in advance for any help.