Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
      }
 });
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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).

share|improve this answer
    
no in my browser i got the alert error message –  Glolita Jan 30 '13 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 '13 at 9:55
    
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); } –  machour Jan 30 '13 at 9:55
    
change your error() function to the one I provided, it will display more accurate error messages –  machour Jan 30 '13 at 9:56
    
it's an internal server error 500 ! –  Glolita Jan 30 '13 at 10:00
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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