1

I have an object as a variable ,so I want to assign this object as an Id my link. I wrote the below code but it does not work.

here is my code :

$(".rooms").each(function(index, element) {
  var policy = $(".policy").val();
  alert(policy)
 $('.search-box2').load('page.html?id=+policy+&debug=true');


});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<div class="rooms">
<input type="text" value="{ &quot;id&quot; : { &quot;provider&quot; : { &quot;provider_id&quot; : &quot;10&quot;, &quot;dmnid&quot; : 2452 }, &quot;NonRefundable&quot; : &quot;false&quot;, &quot;id&quot; : &quot;#1#c2ce302a2032435c96a0b80b8dadc5b2@63a517cd8bca4b318ae398e329509f68&quot; } }" class="policy">
</div>
inaz
  • 1,755
  • 4
  • 20
  • 41

1 Answers1

0

You can use Blob like this:

var obj ='{ &quot;id&quot; : { &quot;provider&quot; : { &quot;provider_id&quot; : &quot;10&quot;, &quot;dmnid&quot; : 2452 }, &quot;NonRefundable&quot; : &quot;false&quot;, &quot;id&quot; : &quot;#1#c2ce302a2032435c96a0b80b8dadc5b2@63a517cd8bca4b318ae398e329509f68&quot; } }',
    b = new Blob([obj], {type: "application/json"}),
    url = URL.createObjectURL(b);

Online demo (jsFiddle)

Ali Soltani
  • 9,589
  • 5
  • 30
  • 55