Home  >  Article  >  Web Front-end  >  JavaScript Eval function usage_javascript tips

JavaScript Eval function usage_javascript tips

WBOY
WBOYOriginal
2016-05-16 18:31:28976browse

It is worth noting
When the input is a Json type, var user = eval(result.d);
When the input is a string, use eval("exception = " result.responseText);

Copy code The code is as follows: > type: "POST",
contentType: "application/json",
url: serviceURL "/UserLogin",
data: "{UserLoginID:'" $('#txtLoginID').val( ) "',UserLoginPW:'" $('#txtLoginPW').val() "'}",  
  dataType: 'json',
    success: function(result)
    {
   var user = eval(result.d);
     //eval("user=" result.d);
     location.href = "Welcome.aspx?userID=" user.UserID
   },
error: function(result, status)
if(status == 'timeout')
alert("The request timed out, please resubmit");
}
    else
     {
     eval("exception = " result.responseText); 🎜>     }
   }
   }
   );

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn