Deal with jQuery.ajax empty content response

I have following "jquery/javascript" code:

$.ajax({
    url: "PpbData",
    data: {RaidId: raidId},
    success: function(text) { $('input#PpbData').val(text); },
    dataType: 'text'
});

code updates a textbox from server using AJAX. It works. But when the response is empty string - I get 'no element found' in firefox console. Not a big deal, but I'd like to get rid of the warning.

Using asp.net mvc I generate response as follows: return Content("");

What would be a simple and elegant way to fix it? (I came up with few hacks, but I don't want a hack)

Answers


Try this:

$.ajax({
    url: "PpbData",
    data: {RaidId: raidId},
    success: function(text) { if(text) { $('input#PpbData').val(text); } },
    dataType: 'text'
});

Or you could just provide some content. Rails scaffold controllers, for instance, return "OK" as the text content on a successful, responseless AJAX call. Gives you an easy test.


Need Your Help

Apache doesn't start after switching to worker mpm

apache centos lamp centos7

I have got a centOS7 server and I've successfully installed LAMP stack , but i've decided to use worker mpm instead of prefork mpm , when i commented this :

Runnable java applet works only when resizing

java applet

This small applet is supposed to move a String from the bottom to the top of applet frame, when it reaches top it should start from the bottom again. Problem is it's only moving when I resize the a...