Struts2 Action,Jquery AJAX call works fine and renders UI correctly in Local Dev Env but not on Production Server -
i try precise possible in explaining situation facing. developing struts 2 based web application , in 1 of page, use jquery 1.4.4 make ajax calls(post) struts2 action classes , xml iterate through , build select box , render on ui.
this piece of code works fine on local 6.1 development environment. not quite on production server(same version). the select box built in local env not in production.
the ajax code below :
$.ajax({ url: 'displaysplitcriteriavaluesaction', type:'post', datatype: "xml", data:{ splitcriteriatype: $.trim($(this).text()) }, success: function( xmlresponse ) { buildselectboxnodropdown(xmlresponse, "serviceactivitiesvalue", "#serviceactivitiesvalueselectiondiv"); $('#serviceactivitiesvalue').bind({ change: function(){ if($(this).val() != '-1'){ makedefault(this,'defvalueforsa'); } } }); } }); function buildselectboxnodropdown(xmldata, selectboxname, wheretodisplayeddiv){ var selectboxhtml = '<select name="'+selectboxname+'" id="'+selectboxname+'"size="12" class="select_optionsbox">'; $(xmldata).find('name').each(function(){ selectboxhtml = selectboxhtml+'<option value="'+$(this).text()+'">'+$(this).text()+'</option>'; }); selectboxhtml = selectboxhtml+'</select>'; $(wheretodisplayeddiv).empty(); $(wheretodisplayeddiv).append(selectboxhtml); }
sample xml structure returning action class
<splitcriteriavalues><name>sample sc value 1</name><name>sample sc value 2</name><name>sample sc value 3</name></splitcriteriavalues>
the surprising part see xml response when debugging using firebug. when compare responses in both dev , prod environments, both match however, there tab called "xml" right beside "response" tab. not sure if makes difference.
is there has accounted when moving 1 environment another? pointers resolve kind of weird behavior helpful.
thanks
i able figure out. though firebug showing response, missing xml tab meant production server never knew content type receiving (or assumed simple text rather xml), quick @ response header confirmed response content type default text/plain.
so had set content type "text/xml" in action class , fixed problem. how local server did not consider content type issue production 1 did.
thanks. sandeep
Comments
Post a Comment