Reputation: 377
I have an ActionResult
which return PartialView()
or new EmptyResult()
, How to detect in JS callback function if returned data
is EmptyResullt()
? I have tried many ways, i.e. compare with null
or with undefined
but no results. console.log(data)
shows blank space. Any tips and tricks? :)
"more code":
Controller:
public ActionResult Checkif(int d)
{
if (d == 2) return new EmptyResult();
else return PartialView();
}
Js function:
function sth ()
{
$.get('/home/Checkif/', {d: 2}, function(data){
if(data === null) //<---- this does not work
{
//then sth;
}
})
}
Upvotes: 2
Views: 2197
Reputation: 21856
Usually, checking for if (data) { // do something }
will work.
To specifically check for empty string, using data === ''
should work.
Upvotes: 2