3

Making this ajax call

    var request = $.ajax({
    type: 'POST',
    url: "http://localhost/thcstore/AJAX/AjaxHawleySS.ashx",
//  url: "http://www.myrealsite.com/thcstore/AJAX/AjaxHawleySS.ashx",
    data: { Name: $('#Name').val(), ShopName: $('#ShopName').val(), StreetAddress: $('#StreetAddress').val(),
        City: $('#City').val(), State: $('#State').val(), ZipCode: $('#ZipCode').val(),
        PhoneNumber: $('#PhoneNumber').val(), ProductType: $('#ProductType').val(), Vendor: $('#Vendor').val(), model: $('#model').val(), Issue2: $('#Issue2').val(), email: $('#email').val()
    },  
    success: function (data){

    }
});

The call works when i'm running my site on my local machine (local host) but not on my real website. I can navigate to my production site ( www.myrealsite.com/thcstore/AJAX/AjaxHawleySS.ashx) without passing variables and it does not throw any http errors. But if i try to pass any data it gives me an http 500 Internal server error. The ajax call is not coming from the same domain as myrealsite.

AJ_Cemprola
  • 143
  • 2
  • 9
  • something won't be processed correctly in the ashx file, seems to be throwing a c# error - turn on debugging in web.config to find out what – Pete Mar 20 '14 at 15:39
  • bottom answer (with no votes) [on here](http://stackoverflow.com/questions/209257/c-sharp-remoting-how-to-turn-off-customerrors). Once you have turned them on then I would browse to the page passing the vars in on the get string (if you can) rather than making an ajax call to it – Pete Mar 20 '14 at 15:59
  • 1
    Sorry just seen that you have said the ajax call isn't on the same domain - you may need to [look at this](http://stackoverflow.com/questions/2558977/ajax-cross-domain-call) – Pete Mar 20 '14 at 16:08

2 Answers2

0

*.ashxis not working on a live server. After researching for a whole day I came to conclusion that, if Your site is running on "HTTPS" protocol or you have changed your protocol http to https, the *.ashx file does not get executed.

So, change https to http and *.ashx will work fine.

I hope this will help a bit.

Paul Kertscher
  • 9,416
  • 5
  • 32
  • 57
-1

Maybe you solved this issue already, but I noticed that in the client code in your post, you are using a fixed URL targeting localhost, i.e. The client browser will try to reach localhost instead of your live domain.

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
Gunnar
  • 1