cross domain posts to ASP.Net MVC app

后端 未结 5 1848
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 15:30

I\'m developing an app where HTML and javascript chunks are delivered down to different clients. I\'m able to GET the html/javascript chunks by adding the following to web

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 15:42

    I fiddled with my ajax call and it seems to be working (compare to the ajax call above):

            $.ajax(
        {
            type: 'POST',
            url: url,
            crossDomain: true,
            data: data,
            dataType: 'json',
            success: function(responseData, textStatus, jqXHR) 
            {
                alert('success');
            },
            error: function (responseData, textStatus, errorThrown) 
            {
                alert('POST failed.');
            }
        });
    

    I removed "contentType: 'application/json'" and "JSON.stringify(...)" calls and I'm able to post to the server.

    I'm not sure how to explain why it's working. Any ideas? Are there any security issues? I'm doing this all on my laptop. I set up 2 different websites via IIS 7. Will this make a difference?

提交回复
热议问题