jquery json anchor tag
I am using jqgrid, and am passing back json fo开发者_JAVA技巧rmatted rows. One of the values of the row is an anchor tag as below:
<a class='class1' href='#' onClick='getFn(); return false;'> text </a>
But The returned JSON converts the values as below:
"\n text\n <\/a>"
It removes all the attributes and also the "tag" at the beginning. Is there a workaround for this kind of problem?
JSON Sample of my resultset
{"ROWS":[[3,"FName1","Lname1","\n text\n <\/a>"]],"PAGE":1.0,"TOTAL":3.0,"RECORDS":1}
So in the above sample, the value "\n text\n <\/a>"
should have been <a class='class1' href='#' onClick='getFn(); return false;'> text </a>
Coldfusion Code:
//append to the array
<cfset arrayAppend(arrayUsers[i],"<a class='class1' href='#' onClick='getFn(); return false;'> text </a>")>
</cfloop>
<cfset i = i + 1>
Final json formatted string to return
<cfset jsonReturn = {total=#totalPages#,page=#Arguments.page#,records=#GetDetails.recordcount#,rows=#arrayUsers#}>
Thanks
Use <cfsavecontent>
:
<cfsavecontent variable="a"><a class='class1' href='#' onClick='getFn(); return false;'> text </a></cfsavecontent>
<cfset arrayAppend(arrayUsers[i], a)>
精彩评论