Reputation: 25
i am sending msg to mobile using ajax posting . i receive msg but it fire error method not success. and what should i pass in data parameter.? here is my code ....
var SendUrl ="here is my send msg URL";
$.ajax({
url: SendUrl,
type: 'POST',
data: "",
success: function (data) {
alert("Success");
},
error: function (e) {
alert("Fail");
}
});
$('#txtmobileNo').val('');
Upvotes: 0
Views: 84
Reputation: 10929
It depends on what the service that you call from looks like. If you are passing json, then json.
If XML then XML and if plain text, then text.
I assume the problem is being created because no data is being passed and you didn't define any data type. Please review your response.
Basically, the data section is the data you send to the server so you send nothing. You need to specify also data type, which is the type of data you send and optionally you can specify content, which is the content type you pass.
Upvotes: 0
Reputation: 2602
In the data property in your ajax options you want to send the object or value that matches your server side params that you are posting to. The data param in your success function is the data that returns from your server code when the call was successful. Your error function is being called most likely because you are posting to a method that requires a parameter to be passed in but you aren't supplying it one (your data property in the ajax options).
Upvotes: 1
Reputation: 251
Try it, you can pass an object which you should to send in data parameter like that
data:{title:"someTitle"}
and you need to set these properties of object in server side.
Upvotes: 0