JavaScript Ajax call always returning error 500 client side ajax call always goes to error,ajax call always,ajax

Im trying to post data back to a webmethod located in Default.aspx

jquery code:

data = "{'saveData':'testtestest'}"

    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "/Default.aspx/SavePins",
        data: data,
        dataType: "json",
        success: function (response) {
            if (response.d) {
                //    var obj = JSON.parse(response.d);
            }
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('#modalContentBox').html('Whoops! There was an error saving!').removeAttr('class').attr('class', 'alert alert-error');
            $('#myModal').modal();
        }
    });

Web Method:

[WebMethod]
public bool SavePins(string saveData)
{
    try
    {
        File.WriteAllText(string.Format("{0}{1}.shane", file_location, "pinsData"), saveData);
        return true;
    }
    catch (Exception)
    {
        return false;
    }
}

The issue is that the Ajax call always returns an error 500 client side. It does not actually post to the server. there is a <form> element with runat="server" in the page. I've added <asp:ScriptManager EnablePageMethods="True" runat="server"/>

Answer:1

to draw a rectangle in google map, I need to know northwest and southeast points to construct a LatLngbounds first. In my situation, I want to draw a rectangle with specific northwest point and a ...

to draw a rectangle in google map, I need to know northwest and southeast points to construct a LatLngbounds first. In my situation, I want to draw a rectangle with specific northwest point and a ...

  1. draw rectangle google maps
  2. draw rectangle google earth

I am extending Backbone views like: var baseView = Backbone.View.extend({ fruits : [], listFruits : function() { console.log(this.fruits); } }); var firstView = baseView.extend({ ...

I am extending Backbone views like: var baseView = Backbone.View.extend({ fruits : [], listFruits : function() { console.log(this.fruits); } }); var firstView = baseView.extend({ ...

  1. backbone view inheritance

I have a controller, simplified for brevity: .controller('myCtrl', ['$scope', 'data', function ($scope, data) { $scope.myVar = testFunction(data.name); function testFunction (name) { ... }; ...

I have a controller, simplified for brevity: .controller('myCtrl', ['$scope', 'data', function ($scope, data) { $scope.myVar = testFunction(data.name); function testFunction (name) { ... }; ...

  1. jasmine test scope variable
  2. angularjs test scope variable
  3. test-path variable scope
  4. junit test variable scope
  5. java test variable scope
  6. javascript test variable scope

I am trying to replace all the content, depending on what it is, with a corresponding unicode character in all anchors that are descendants of the class nav ( .nav a ). But this javascript / jQuery ...

I am trying to replace all the content, depending on what it is, with a corresponding unicode character in all anchors that are descendants of the class nav ( .nav a ). But this javascript / jQuery ...