Possible Bug in jquery.Form (from malsup.com)
Hi there,
possibly found a bug in this plugin and want to ask if anyone can verify this or have found the same issue.
I want to get the result of an ajax-script which is encoded in json (using php's json_encode();).
However, if I include "<" into the result-array, nothing happens and even the success-method is not called.
It's a bit irritating because on another script which is mostly the same in each line, the success-method is called without problem.
I asked a friend programming alot with jquery and he said that it seems to be a bug in line around 337 (or something like that) and that the xhr-object is incorrect.
Here is my code I used:
HTML:
<form action='http://noxx/mychars/layer/create/ajax' method='POST' id='uploadLayer' enctype='multipart/form-data'>
- ...
- </form>
The content is not relevant because I set the result sent by the ajax-script to a hardcoded value to test this isssue.
JS:
- $(document).ready(function() {
$('#uploadLayer').ajaxForm({
success : uploadLayerResult,
dataType: "json",
resetForm: true
});
});
function uploadLayerResult(responseText, statusText, xhr, form) {
alert("Function as been called!");
}
Same here, the content of uploadLayerResult() is not relevant because we just want to know if the function is even called.
Ajax script, line of return:
- die(json_encode($myReturnValue));
If die() is really so sexy, we can discuss later ;)
And now I tested it with two values:
The first one gives no "error". The success-method is called and I get the alert()-box.
- array('messages'=>"test", 'grouplist'=>"case")
FireBugs output (after json_encode();) is:
{"messages":"test","grouplist":"case"}
The second one gives me nothing, no error occurrs and the success-method is *not* called:
- array('messages'=>"<test", 'grouplist'=>"case")
FireBug:
{"messages":"<test","grouplist":"case"}
Nothing happends.
I tested it several times with ">" and other special-chars, it seems only "<" is the reason the success-method is not called.
As I said at the beginning of my post, it's irritating because another script returns a whole "page" in html and the method is called successfully but I cannot track down why.. the scripts are mostly the same desist from the return values
Any helpful ideas?
Greetings.
//Edit:
I'm using jquery v1.5.1 and jquery.Form-Plugin 2.67 (12-MAR-2011)