MrS1ck
MrS1ck

Reputation: 237

Error 500 when posting data to ASMX web service via jQuery "Error 500 Invalid Response Format"

So I've got a webservice, http://Komputerz4Kidz.com/mailer/Service1.asmx/SendMail is the URL. It is an exact replica, save for the namespace and a variable or two, of a script I threw together to send mail via jQuery using POST.

It's very simple, not a lot going on here:

function ContactSubmit() {
var Name = $('input:text[name=pickup_name]').val();
var Email = $('input:text[name=pickup_email]').val();
var Message = $('textarea[name=pickup_message]').val();
var Date = $('input:text[name=pickup_date]').val();
$.ajax({

type: "POST",
url: "http://Komputerz4Kidz.com/mailer/Service1.asmx/SendMail",
data: {pickup_name: Name, pickup_email: Email, pickup_message: Message, pickup_date:     Date},

success: ContactSuccess,

error: function (x, y, z)     {console.log(x);console.log(y);console.log(z);alert('ERROR');}

});

}

function ContactSuccess(){
alert("Thanks! Your message has been sent and I will be in touch shortly!");

};

and the only error that logs is "Error 500: Invalid response format. "

I looked around stack overflow, and found a few solutions but none applied to me.

Like I said, the example works on another site and is hosted from the same server. It's got it's own application pool in IIS, and that is setup properly to .NET 4.0 integrated.

If it helps, you can test the script live at Komputerz4Kidz.com all the way at the bottom is a contact form.

Thanks for any help, and I'll answer any questions!

PS: WEB SERVICE WORKS FINE FROM SERVER AND FUNCTIONS 100% when from the server I run:

komputerz4kidz.com/mailer/service1.asmx?op=SendMail

Upvotes: 0

Views: 447

Answers (2)

000
000

Reputation: 27247

I took a look at the url, which I shouldn't have had to do. Expecting people to visit strange URLs is a bad thing.

It responds with "Missing parameter: _name." What does that sound like to you?

Anyway, it looks like your request is supposed to be:

data: {_name: Name, _email: Email, _message: Message, _date:     Date},

Also! var Date is bad. Date is already a builtin javascript class. Try to not overwrite javascript builtins!

Upvotes: 1

Milche Patern
Milche Patern

Reputation: 20452

Try this, presuming it's the params names : ( i figured out visiting your link )

before :

data: {pickup_name: Name, pickup_email: Email, pickup_message: Message, pickup_date:     Date},

after :

data: {_name: Name, _email: Email, _message: Message, p_date: Date},

Upvotes: 2

Related Questions