I am using jquery:
$.get(URL, function(data){
if(data == 'no_credits'){
alert("no credits");
return;
}
else{
// WHY HERE>?!
开发者_运维百科 }
and my problem is that url return 'no_credits' but code goes to else
block code, please help!
EDIT : alert(data);
prints no_credits
You probably have trailing spaces or capitalization differences.
Try
if($.trim(data).toLowerCase() === 'no_credits'){
Try this:
$.get(URL,function(data){...},'text');
Your function is outside the $.get function, so of course it doesn't get the server's response as argument.
Have you tried dumping the data object ? do a console.log(data);
in Firefox (with installed firebug) and check the firebug console. I think the data is not the output of the server but a response object.
to send data to front end from backend code....make sure u r not using any function which adds something by itself...like println() function of Java Streams adds one "\n" at the end of string and then sends..use print() function instead...
精彩评论