1

I'm trying to send some data to an aspx page by clickin on button but it doesn't seem to work by using jQuery Ajax Post ,however if I just chage the ajax type to GET it works fine ! but I do really want to make it with ajax post method since my transferred data size is really huge!

 $('#sendDataBtn').click(function () {
 selecteddata = document.getElementById("<%=textbox.ClientID%>").value; //might be over 1800 caracters
 $.ajax({
      url: '<%=SPContext.Current.Web.Url %>/_admin/CreateFilefromRecievedData.aspx',
      type: 'POST',
      dataType: 'text',
      data: { "data":selecteddata } ,
      headers: {
                "accept": 'application/x-www-form-urlencoded',
                "content-type": 'application/x-www-form-urlencoded',
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            }, //==> this fixed everything :)
      error: function () {
          alert("error");
      },
      success: function (data) {
         alert(data);
      }
 });

1 Answer 1

0

What does "doesn't seem to work" mean in your case?

Did you verify that the ajax post query is actually being sent (you can see that in your browser developer console).

9
  • no in my browser i got the alert error message
    – Glolita
    Jan 30, 2013 at 9:52
  • it doesn't even enter to my CreateFilefromRecievedData.aspx page, I found this but it's with layout folder facebook.com/…
    – Glolita
    Jan 30, 2013 at 9:55
  • error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); }
    – machour
    Jan 30, 2013 at 9:55
  • change your error() function to the one I provided, it will display more accurate error messages
    – machour
    Jan 30, 2013 at 9:56
  • it's an internal server error 500 !
    – Glolita
    Jan 30, 2013 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.