It looks like you're new here. If you want to get involved, click one of these buttons!
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
console.log("i was called");
function send(){
var your_basket=[{
"tradingsymbol": "INFY",
"exchange": "NSE",
"transaction_type": "BUY",
"order_type": "MARKET",
"quantity": 10
}];
document.getElementById("basket").value =JSON.stringify(your_basket);
document.getElementById("basket-form").submit();
};
</script>
<form method="post" id="basket-form" action="https://kite.trade/connect/basket">
<input type="hidden" name="api_key" value="4slvxxxxxxw0zgvk" />
<input type="hidden" id="basket" name="data" value="" />
<input type="submit" value="Submit"> //button-submit
</form>
</body>
</html>
output :
The problem is when the code is being executed. You are calling the element code gets before the DOM is finished loading. So, you can fix this by moving your JS code after the form initialization i.e at the end of the code.
Same Result
For your reference Please have a look :
https://jsfiddle.net/ayxfLdj9/1/
Can you correct the code and post
You have defined send() JS method but aren't calling the same when the Submit button is clicked.
You need to call send() when submit button is clicked,as shown below:
<input type="submit" value="Submit" onclick="send()">
{"status":"error","message":"Invalid connect session.","data":null,"error_type":"InputException"}
Now different error, "Invalid Connect Session" first error was "Invalid orders payload", first error resolved, but new error came. Thanks for your effort, Please have a look
Working fine for me.Can you check fiddle code here and make the changes ?
Thanks, Working now