javascript - JSON does not post data to the requested URL -
trying post data @ url: "
$(function() { var frm = $(document.myform); var data = "?lm_po_id=154668&authentication=thisisauth&description=thisisdesc";//json.stringify(frm.serializearray()); //var data = json.stringify(frm.serializearray()); // tried alert(data + "i post this:\n\n" + data); $.postjson = function (url, data, callback) { $.ajax({ 'url': frm.attr("action"), 'type': 'post', 'processdata': false, 'data': json.stringify(data), contenttype: 'application/json', success: function (data) { callback(json.parse(data)); }, }); }; });
this call right function when check in debug mode parameters have null values, can 1 me wrong doing. here html form
<form action="http://192.168.0.124:8080/ilex-ws/service/ilexmobile/poimageupload" name="myform" method="post" enctype="multipart/form-data"> <input type="text" value="158664" name="lm_po_id" /><br /> <input type="text" value="authcodemd5" name="authentication" /><br /> <input type="text" value="584" name="imagenumber" /><br /> <input type="text" value="imgname.png" name="name" /><br /> <input type="text" value="this desc" name="description" /><br /> <input type="file" value="" name="uploadedimage" /><br /> <input type="button" value="submit" onclick="javascript:document.myform.submit()"/><br /> </form>
thanks in advance....
the thing javascript alert string.
you never bind event handler form's submit method, , if did wouldn't fire since use form.submit()
submit form instead of submit button. (so submits form encoded data instead of json encoded data).
you store function in $.postjson
, never call it, , has local variable called data
mask var data = "?lm_po...
anyway (not make sense use value since string , run json.stringify
on data
).
Comments
Post a Comment