I'm designing 2 websites, the first in https://localhost:44300/
and the second in https://localhost:44301/
.
In the Home controller of the second localhost, I declared:
[HttpPost]
public ActionResult GetPictureUrl
{
return Json(new { success = true, url = "~/Content/Images/Img001.png" });
}
I wanna get that json in the first localhost after clicking button:
<button>Get picture url</button>
<script>
$('button').click(function () {
$.ajax({
url: 'https://localhost:44301/Home/GetPictureUrl',
type: 'POST',
//dataType: 'jsonp' //I'd tried this but still not working
}).done(function (data) {
if (data.success) {
alert(data.url)
}
})
})
</script>
Here is the error I'd got in Console log:
Why GET
?
I'd set type: 'POST'
in the ajax, and I didn't send anything to the controller as a parameter. But as you can see above, what were callback
and _
?